Reputation: 575
(1) In a multi-threaded process,If one thread is busy on I/O will the entire process be blocked?
(2) Which is better to use a mutex or a binary semaphore ? When should I use a mutex and when should I use a binary Semaphore ?
Upvotes: 0
Views: 200
Reputation: 1581
1) In a SMP environment multiple thread can run in parallel(on different cpu). In a single CPU environment, only one thread would be running at a time.
2) read this diff-binary-semaphore-and-mutex
Upvotes: 0
Reputation: 213351
1). Well, at a time only one thread is allocated the CPU in multithreaded application. If you are saying that your thread is regularly busy with I/O, then practically it can happen that all other threads keep waiting in queue to get CPU allocated to them. It depends upon the CPU allocation algorithm
used. Like if thread are using Time-Sharing
algorithm, then of course on completion of time, current thread will be send to the back of the queue.
2). Check out this post: - Difference between binary semaphore and mutex
Upvotes: 1