Is it legal to initialize a linux kernel semaphore to a negative number? -


say want wake task after n separate events have occurred. legal initialize semaphore 1 - n, , down() it, wake after each of events have up()'d it?

i don't think so.

(1) semephore.count declared unsigned int. see semaphore definition:

    struct semaphore {         spinlock_t      lock;         unsigned int        count;         struct list_head    wait_list;     }; 

(2) down() function check count value before decrease it, make sure count not negative.

unless implement 1 mechanism, can not use semaphore directly accomplish requirement.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -