Approaches of Mutual Exclusion
•Software Approaches
•Hardware Support
•Semaphores
•Monitors
•Message Passing
Semaphores
•Special variable called a semaphore is used for signaling. •If a process is waiting for a signal, it is blocked until that signal is sent.
•Wait and Signal operations cannot be interrupted. •Queue is used to hold processes waiting on the semaphore.
Semaphores字符常量池是什么意思
•Semaphore is a variable that has an integer value.
–May be initialized to a nonnegative number .
–Wait and Signal are primitives (atomic, cannot be interrupted and each routine can be treated as an indivisible step).
Semaphores
•Wait operation decrements the semaphore value - wait(s):s-1
- wait操作:申请资源且可能阻塞自己(s<0)
•Signal operation increments semaphore value
- signal(s):s+1
- signal操作:释放资源并唤醒阻塞进程(s≤0)
Types of Semaphores
•General Semaphore (通用信号量)
–通用信号量是记录型,其中一个域为整型,另一个域为队列,其元素为等待该信号量的阻塞进程(FIFO)
•Binary Semaphore (二进制信号量)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论