POSIX threads and fairness (semaphores)

前端 未结 2 1548
广开言路
广开言路 2021-01-15 18:30

I have created a program in C that creates 2 buffers. The buffer indices hold single characters, \'A\' or \'b\' etc... In order to learn more about multithreading, I creat

相关标签:
2条回答
  • 2021-01-15 18:53

    The POSIX standard actually says that "the highest priority thread that has been waiting the longest shall be unblocked" only when the SCHED_FIFO or SCHED_RR scheduling policy applies to the blocked thread.

    If you're not using one of those two realtime scheduling policies, then the semaphore does not have to be "fair".

    0 讨论(0)
  • 2021-01-15 18:58

    Multi-threaded software only makes sense when

    1. You have multiple core to play with
    2. Some algorithms are easier to program

    How do you define fair. Surely it is better if a core has nothing to do then they take on the work. Does it matter if one core never gets a lookin?

    0 讨论(0)
提交回复
热议问题