Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   Help!!!!!!!!!!! (http://www.programmingforums.org/showthread.php?t=15751)

nannu May 2nd, 2008 12:16 PM

Help!!!!!!!!!!!
 
Hello now that I have your attention. Just a quick question, don't know if its been asked before, but is there a good site where I can find a tutor for one of my classes. Or is someone on here willing to help me out with some of my programs. Ive tried multiple sources including my school and no one is available for help including the professors. I am even willing to PAY. I just need someone to help me with the concepts of the programs that I need to write. Guess MONEY TALKS doesn't work anymore with poeple. I was hoping to understand what Im doing in my class so I can use it in my future career.
I am looking for someone that knows about OPERATING SYSTEMS using C/C++. If you or someone you know on this forum can help. Pleaseeeeeee just get back to me ASAP. Also if you want you can contact me via e-mail.

<snipped email>

Don't even ask about what the e-mail address means, at school I was called dr.Abbey for some reason.

Thanks in advance

Ancient Dragon May 2nd, 2008 3:28 PM

Re: Help!!!!!!!!!!!
 
Why don't you just post your question(s) here? Someone is bound to answer you -- and for free.

nannu May 2nd, 2008 4:03 PM

Re: Help!!!!!!!!!!!
 
Can someone please assist me in how I should approach this problem. Its for my operating class.

Write a program with two threads sharing a variable. One threads repeatedly
subtracts a constant values from the shared variable, while the second
repeatedly adds the same value. If the number of transactions that the threads
execute is the same, then the value of the shared variable after the threads
complete should be the same as the initial value – that is assuming access to the
shared variable is mutually exclusive.

First write the program without any code to protect the critical section, and test it
with a large number of iterations (hopefully the final value should deviate from
the original). Then incorporate a mutex lock into the solution and test it again.
That should ensure data consistency, and the program output should confirm it.

Freaky Chris May 2nd, 2008 4:07 PM

Re: Help!!!!!!!!!!!
 
there are reasons for removing emails, they don't just do it to be cute

titaniumdecoy May 2nd, 2008 5:34 PM

Re: Help!!!!!!!!!!!
 
Why are you in (or rather how did you get into) an Operating Systems class when you clearly have no clue how to program?

No one will do your homework for you. If you want help, post the code you have written and make it clear which part(s) you need help with.

JD-Salinger May 3rd, 2008 4:35 AM

Re: Help!!!!!!!!!!!
 
you're a teacher?

nannu May 5th, 2008 12:27 PM

Re: Help!!!!!!!!!!!
 
WOW OK, first of all I'm a financing major. The only reason I am taking this class is just to familiarize myself with the technical world that we all live in. My company is paying for the class and this was one of the classes being offered. So I just thought it would be good for me to familiarize myself with something new. I'm sorry that I don't know how this works, but instead of just bashing on me, you guys should not reply if you don't have anything useful to say to me that I can use for this class. It's kind of my fault too, because I should have mentioned it earlier. I have posted this question before too and someone left me some useful websites where I can retrieve some information, but I am still having some trouble. Not being a computer major, makes it difficult to understand what is going on. I am good at picking up information quickly, but this class has become a challenge for me that I really enjoy. I just thought that it would be a good experience because I am really interested in computers and how they work, and some of the people in the IT department at work told me that this would be a good skill to have and to learn something new.
Thanks

Alias May 5th, 2008 1:50 PM

Re: Help!!!!!!!!!!!
 
Yeah, go on, you open a (cool, calm and collective) can, man!

Most people with a forte in programming tend to have the opinion that if you don't have some kind of natural understanding then just give up before you start, or 'they' just seem to have forgotten that there is actually a learning curve to conquer, then a few more.

Once you get over the first hurdle you will be subject to a huge revelation, so how far are you now? I understand your overall experience in this area is zero percent however, what have you learned even in the past few days? What resources do you have? I would get some book suggestions if I were you and those sites you were directed to - come here with your uncertainties on particular elements (tackling a relatively big problem as a whole right now will only hinder your development, break it up). Although your class is Operating System based I would recommend that you personally develop general programming skills using C or C++ (pick one), as you will go nowhere without this experience.

nannu May 5th, 2008 4:26 PM

Re: Help!!!!!!!!!!!
 
Thank you very much ALIAS
OK, I am using Microsoft Visual C++ for all of my C++ programming. We have done some very basic code just to get an overview of what is going on. I have found some code below, this code is pretty long compared to what we have done as we skimmed over the programs. But in MS Visual C++ how would I put this into the program.

THREADS:
:

  1. #include <pthread.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <stdio.h>
  5.  
  6. int myglobal;
  7.  
  8. void *thread_function(void *arg) {
  9.   int i,j;
  10.   for ( i=0; i<20; i++ ) {
  11.     j=myglobal;
  12.     j=j+1;
  13.     printf(".");
  14.     fflush(stdout);
  15.   sleep(1);
  16.     myglobal=j;
  17.   }
  18.   return NULL;
  19. }
  20.  
  21. int main(void) {
  22.  
  23.   pthread_t mythread;
  24.   int i;
  25.  
  26.   if ( pthread_create( &mythread, NULL, thread_function, NULL) ) {
  27.     printf("error creating thread.");
  28.     abort();
  29.   }
  30.  
  31.   for ( i=0; i<20; i++) {
  32.     myglobal=myglobal+1;
  33.     printf("o");
  34.     fflush(stdout);
  35.     sleep(1);
  36.   }
  37.  
  38.   if ( pthread_join ( mythread, NULL ) ) {
  39.     printf("error joining thread.");
  40.     abort();
  41.   }
  42.  
  43.   printf("\nmyglobal equals %d\n",myglobal);
  44.  
  45.   exit(0);
  46. }
  47.  
  48. OK what I am doing is when I open up the project I create the work space and give it a name. Now when I copy this code into the project and click compile, I get 1 error saying "Cannot open include file: 'pthread.h': No such file or directory". Now I know that in C++ you can have are .cpp file and a .h file. Now how can I prevent this from happening. I tried changing it up a little. I created a header file and pasted this part in it:
  49. #include <iostream>
  50. //#include <FK2008Sample2.h>
  51.  
  52. #include <pthread.h>
  53. #include <stdlib.h>
  54. #include <unistd.h>
  55. #include <stdio.h>
  56. #include <FK2008Sample>
  57. int myglobal;
  58.  
  59. void *thread_function(void *arg) {
  60.   int i,j;
  61.   for ( i=0; i<20; i++ ) {
  62.     j=myglobal;
  63.     j=j+1;
  64.     printf(".");
  65.     fflush(stdout);
  66.   sleep(1);
  67.     myglobal=j;
  68.   }
  69.   return NULL;
  70. }
  71.  
  72. and then I created a .cpp file and pasted this in it:
  73. using namespace std;
  74.  
  75. int main(void) {
  76.  
  77.   pthread_t mythread;
  78.   int i;
  79.  
  80.   if ( pthread_create( &mythread, NULL, thread_function, NULL) ) {
  81.     printf("error creating thread.");
  82.     abort();
  83.   }
  84.  
  85.   for ( i=0; i<20; i++) {
  86.     myglobal=myglobal+1;
  87.     printf("o");
  88.     fflush(stdout);
  89.     sleep(1);
  90.   }
  91.  
  92.   if ( pthread_join ( mythread, NULL ) ) {
  93.     printf("error joining thread.");
  94.     abort();
  95.   }
  96.  
  97.   printf("\nmyglobal equals %d\n",myglobal);
  98.  
  99.   exit(0);
  100.  
  101. }

But I am still getting errors: I know I am making a silly mistake that will probably take a second to change.

Thanks in advance

The Dark May 5th, 2008 7:00 PM

Re: Help!!!!!!!!!!!
 
See my reply in your other thread.


All times are GMT -5. The time now is 6:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC