简体   繁体   English

如果5个进程在semphore中等待会发生什么?

[英]What happens if 5 processes waiting in a semphore?

Im using semaphore.h, what is happening if 5 child processes waiting on sem_wait while another child process unlocking the semaphore sem_post ? 我使用semaphore.h,如果5个子进程在sem_waitsem_wait而另一个子进程解锁信号量sem_post什么? Are they all going to be unlocked? 它们都将被解锁吗?

No, only one will be unblocked. 不,只有一个会被解锁。 RTFM. RTFM。

sem_wait sem_wait

sem_post sem_post

If many processes are block, then one will be chosen to be unblocked, which one is up to OS. 如果许多进程被阻塞,那么将选择一个进程被解除阻塞,其中一个进程取决于操作系统。 Scheduler will choose one. 调度程序将选择一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 等待用户输入的进程实际发生了什么? - What actually happens to a process waiting for user input? 当pthread在等待互斥锁时死机会发生什么? - What happens when a pthread dies while waiting on a mutex? 当很多进程打开同一个特殊文件时会发生什么? - What happens when a lot of processes open the same special file? 在fork()进程中没有针对父进程的操作时会发生什么? - What happens when there are no actions for parent process during fork() processes? 如果我删除其他进程的共享内存会发生什么? - What happens if I remove shared memory of other processes? 我在XV6中杀了进程“A”,对于“A”的子进程会发生什么 - I kill process “A” in XV6 , what happens to child processes of “A” 当两个进程试图访问信号量= 0的关键部分时会发生什么? - What happens when two processes are trying to access a critical section with semaphore = 0? 当两个进程等待同一个孩子时会发生什么? - What happens when two processes wait for the same child? 当两个进程写入mmaped文件的相同部分时会发生什么? - What happens when two processes write to same portion of a mmaped file? 在等待来自多个进程的信号时sigwait出了什么问题 - What's wrong with sigwait while waiting signals from multiple processes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM