prevent linux thread from being interrupted by scheduler

后端 未结 5 609
别那么骄傲
别那么骄傲 2020-12-01 10:49

How do you tell the thread scheduler in linux to not interrupt your thread for any reason? I am programming in user mode. Does simply locking a mutex acomplish this? I wa

5条回答
  •  长情又很酷
    2020-12-01 11:46

    You should architect your sw so you're not dependent on the scheduler doing the "right" thing from your app's point of view. The scheduler is complicated. It will do what it thinks is best.

    Context switches are cheap. You say

    I would be wasting cpu cycles with context switches.

    but you should not look at it that way. Use the multi-threaded machinery of mutexes and blocked / waiting processes. The machinery is there for you to use...

提交回复
热议问题