943,862 Members | Top Members by Rank

Ad:
Apr 9th, 2008
0

semaphores

Expand Post »
was hoping someone could help me with semaphores...im a little confused

heres the question:

There are three kinds of processes in a system: type A, type B and type C. There are
many processes of types A and B, but only one process of type C. The type C process
cannot begin its task (Task_C()) until n processes of type A or m processes of type B
finish their respective tasks. More specifically, the type C process must block itself until
enough processes of type A or type B complete their tasks. Write synchronization code
for the three types of processes using semaphores. Use the templates below for each
process type. Hint: You’ll also want to use integer counts.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cppsevennine is offline Offline
3 posts
since Apr 2008
Apr 9th, 2008
0

Re: semaphores

crosspost
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Apr 15th, 2008
0

Re: semaphores

python Syntax (Toggle Plain Text)
  1. a = b = 0 # shared counters
  2. sem(0) # semaphore initialized to 0
  3.  
  4. func_A: # code for type A process
  5. a = a + 1
  6. sem.V
  7.  
  8. func_B: # code for type B process
  9. b = b + 1
  10. sem.V
  11.  
  12. func_C: # code for type C process
  13. while (a < n && b < m):
  14. sem.P
  15. # critical section
Reputation Points: 10
Solved Threads: 2
Newbie Poster
jaux is offline Offline
15 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Computer Science Forum Timeline: Pentium
Next Thread in Computer Science Forum Timeline: got a few homework questions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC