由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 为啥说semaphore是进程间的一种通信机制?
相关主题
为什么说semaphore是一种进程间的通信方式。Google及其它面经 (长,慎入)
failed bloomberg phone interview交通灯OO design哪道题在哪里可以找到??
昨天面试遇到的两道题,编程语言和数据库设计相关Bloomberg电面面经
攒人品。面试经历(1)embedded software engineer面经
昨天onsite被问到的 multithreading 题目某start-up on-site 小感
人生中第一次面试一道涉及OO,算法,多线程的设计题
multi thread复习请教总是过不了2小时内的码工onsite
又tmd的面砸了一个,还是贴贴面经L家电面题目
相关话题的讨论汇总
话题: mutex话题: thread1话题: semaphore话题: 进程话题: semaphonre
进入JobHunting版参与讨论
1 (共1页)
r****o
发帖数: 1950
1
一直觉得很奇怪,semaphore不是进程间的同步机制吗?
为啥老见人说semaphore是进程间的通信机制呢? 光靠semaphore能实现连个进程间的通
信吗?
l*******y
发帖数: 1498
2
mutex是专门用来同步的, semaphonre既可以用来同步也可以用来通信。因为mutex只
能由拥有mutex的那个进程释放,而semaphonre可以由非拥有的进程释放。这也是mutex
和 binary semaphonre的一个主要区别吧。
Consider I/O examples, we pick up a binary semaphore to wait for some kind
of I/O, when the I/O comes, task picks up the byte, the task then releases
the same semaphore. This cannot be done with a mutex.
c****a
发帖数: 11
3
你的i/o example里面 为什么不能用mutex?

mutex

【在 l*******y 的大作中提到】
: mutex是专门用来同步的, semaphonre既可以用来同步也可以用来通信。因为mutex只
: 能由拥有mutex的那个进程释放,而semaphonre可以由非拥有的进程释放。这也是mutex
: 和 binary semaphonre的一个主要区别吧。
: Consider I/O examples, we pick up a binary semaphore to wait for some kind
: of I/O, when the I/O comes, task picks up the byte, the task then releases
: the same semaphore. This cannot be done with a mutex.

l*******y
发帖数: 1498
4
thread1 waits for the I/O to complete, thread2 is responsible for completing
the I/O operation. thread1 get the semaphonre first, thread2 realse it then
. Then thread1 find the I/O operation completes and can do the following
things. This is a kind of communication.
If use mutex, if thread1 get the mutex, only thread1 can release the mutex.

【在 c****a 的大作中提到】
: 你的i/o example里面 为什么不能用mutex?
:
: mutex

1 (共1页)
进入JobHunting版参与讨论
相关主题
L家电面题目昨天onsite被问到的 multithreading 题目
embedded Linux ,面试了几次,都问这个问题了。不知道答案??人生中第一次面试
qualcomm 新鲜电面面经multi thread复习请教
two functons and two threads又tmd的面砸了一个,还是贴贴面经
为什么说semaphore是一种进程间的通信方式。Google及其它面经 (长,慎入)
failed bloomberg phone interview交通灯OO design哪道题在哪里可以找到??
昨天面试遇到的两道题,编程语言和数据库设计相关Bloomberg电面面经
攒人品。面试经历(1)embedded software engineer面经
相关话题的讨论汇总
话题: mutex话题: thread1话题: semaphore话题: 进程话题: semaphonre