Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2008, 12:16 PM   #1
nannu
Newbie
 
Join Date: Apr 2008
Posts: 19
Rep Power: 0 nannu is on a distinguished road
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

Last edited by Ancient Dragon; May 2nd, 2008 at 3:27 PM. Reason: removed email
nannu is offline   Reply With Quote
Old May 2nd, 2008, 3:28 PM   #2
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 529
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Help!!!!!!!!!!!

Why don't you just post your question(s) here? Someone is bound to answer you -- and for free.
__________________
I Like Ike. Vote for Dwight Eisenhower this November.
--This message brought to you by the the Procrastinators Club Of America.
Ancient Dragon is offline   Reply With Quote
Old May 2nd, 2008, 4:03 PM   #3
nannu
Newbie
 
Join Date: Apr 2008
Posts: 19
Rep Power: 0 nannu is on a distinguished road
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.

Last edited by nannu; May 2nd, 2008 at 4:16 PM.
nannu is offline   Reply With Quote
Old May 2nd, 2008, 4:07 PM   #4
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Help!!!!!!!!!!!

there are reasons for removing emails, they don't just do it to be cute
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is offline   Reply With Quote
Old May 2nd, 2008, 5:34 PM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 839
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
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.
titaniumdecoy is offline   Reply With Quote
Old May 3rd, 2008, 4:35 AM   #6
JD-Salinger
Unknown
 
JD-Salinger's Avatar
 
Join Date: Apr 2008
Location: unknown
Posts: 79
Rep Power: 1 JD-Salinger is on a distinguished road
Re: Help!!!!!!!!!!!

you're a teacher?
__________________
-------------------------------------------------------------------------
I thought what I'd Do was, I'd pretend to be one of those deaf mutes
------------------------------------------------------------------------
JD-Salinger is offline   Reply With Quote
Old May 5th, 2008, 12:27 PM   #7
nannu
Newbie
 
Join Date: Apr 2008
Posts: 19
Rep Power: 0 nannu is on a distinguished road
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
nannu is offline   Reply With Quote
Old May 5th, 2008, 1:50 PM   #8
Alias
Newbie
 
Join Date: Oct 2007
Posts: 29
Rep Power: 0 Alias is on a distinguished road
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.
Alias is offline   Reply With Quote
Old May 5th, 2008, 4:26 PM   #9
nannu
Newbie
 
Join Date: Apr 2008
Posts: 19
Rep Power: 0 nannu is on a distinguished road
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:
c Syntax (Toggle Plain Text)
  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

Last edited by Ancient Dragon; May 5th, 2008 at 8:13 PM. Reason: add code tags
nannu is offline   Reply With Quote
Old May 5th, 2008, 7:00 PM   #10
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
Re: Help!!!!!!!!!!!

See my reply in your other thread.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:35 PM.

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