Next: Summary
Up: Semaphores: Implementation
Previous: Implementation
  Contents
struct sema
This is the type for declaring semaphores defined in sema.h. This structure has variables
- struct sema_wait_que wq for maintaining the waiting threads on
the semaphores
- int count for maintaining the number of free semaphore resources
- spinlock_t lock a spin-lock for protecting the particular semaphore
struct sema_wait_que
This is type used for maintaining a queue of threads waiting on a
semaphore. It is defined in sema_que.h. The main variables of this
structure are
- struct sema_wait_que *next,*prev for maintaining the queue itself
- struct tcb *t pointer to tcb of the waiting thread
- struct sema *sem back pointer to semaphore
- struct sema_timeout_que *tnode pointer to node maintaining the
timeout information for the waiting thread.
struct sema_timeout_que
This is the type used to maintain the timout information for various
sema_wait functions . It is defined in sema_que.h. The main variables
of this structure are
- oskit_u32_t time in terms of numbers of jiffies after which
timeout should occur.
- struct sema_timeout_que *next,*prev for maintaining the timeout
queue itself.
- struct sema_wait_que *wnode backpointer to the node of queue of
threads waiting on the semaphores.
struct sema_timeout_que global_stq
This global variable is used to maintain the timeouts.
spinlock_t global_sema_lock
This global variable is used to lock the semaphore library data structures.
void sema_time_handler(void)
This function is called by the kernel periodically & it updates
global_stq removing threads & associated structures, whose timeouts
have happened from the various queues.
Next: Summary
Up: Semaphores: Implementation
Previous: Implementation
  Contents
Soumyadeb Mitra
2002-08-07