Subversion Repositories HelenOS-historic

Rev

Rev 384 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 384 Rev 413
Line 40... Line 40...
40
 * @param s Semaphore.
40
 * @param s Semaphore.
41
 * @param val Maximal number of threads allowed to enter critical section.
41
 * @param val Maximal number of threads allowed to enter critical section.
42
 */
42
 */
43
void semaphore_initialize(semaphore_t *s, int val)
43
void semaphore_initialize(semaphore_t *s, int val)
44
{
44
{
45
    pri_t pri;
45
    ipl_t ipl;
46
   
46
   
47
    waitq_initialize(&s->wq);
47
    waitq_initialize(&s->wq);
48
   
48
   
49
    pri = cpu_priority_high();
49
    ipl = interrupts_disable();
50
 
50
 
51
    spinlock_lock(&s->wq.lock);
51
    spinlock_lock(&s->wq.lock);
52
    s->wq.missed_wakeups = val;
52
    s->wq.missed_wakeups = val;
53
    spinlock_unlock(&s->wq.lock);
53
    spinlock_unlock(&s->wq.lock);
54
 
54
 
55
    cpu_priority_restore(pri);
55
    interrupts_restore(ipl);
56
}
56
}
57
 
57
 
58
/** Semaphore down
58
/** Semaphore down
59
 *
59
 *
60
 * Semaphore down.
60
 * Semaphore down.