We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a79a00f commit 5869d4fCopy full SHA for 5869d4f
1 file changed
Theorie/Threads/coordination.rst
@@ -59,12 +59,15 @@ Les deux principales fonctions de manipulation des sémaphores sont `sem_wait(3)
59
60
int sem_wait(semaphore *s)
61
{
62
- s->val=s->val-1;
63
- if(s->val<0)
64
- {
65
- // Place this thread in s.queue;
66
- // This thread is blocked;
67
- }
+ if(s->val>0)
+ {
+ s->val=s->val-1;
+ }
+ if(s->val==0)
68
+ // Place this thread in s.queue;
69
+ // This thread is blocked;
70
71
}
72
73
La fonction `sem_post(3)`_ quant à elle peut schématiquement s'implémenter comme suit :
@@ -75,7 +78,7 @@ La fonction `sem_post(3)`_ quant à elle peut schématiquement s'implémenter co
75
78
int sem_post(semaphore *s)
76
79
77
80
s->val=s->val+1;
- if(s.val<=0)
81
+ if(s.val==0)
82
83
// Remove one thread T from s.queue;
84
// Mark thread T as ready to run;
0 commit comments