简体   繁体   English

Linux进程和线程调度

[英]Linux process and threads scheduling

I'm playing around with linux scheduling with sched.h and bump into some questions. 我正在玩sched.h的linux调度并遇到一些问题。

From what I know, Linux scheduler do not treat threads and processes differently when scheduling. 据我所知,Linux调度程序在调度时不会以不同方式处理线程和进程。 Threads are just like process which shares common resources. 线程就像共享公共资源的进程一样。

Ok, Say I have Process-A and it is set to CPU core 0 and SCHED_FIFO property is set; 好吧,假设我有Process-A并且它被设置为CPU核心0并且设置了SCHED_FIFO属性; which will runs until another higher priority tasks kicks in. If Process-A creates a new thread, will the thread inherit the same property? 这将运行,直到另一个更高优先级的任务开始。如果Process-A创建一个新线程,该线程将继承相同的属性吗? (ie be bind to CPU 0 with SCHED_FIFO properties or will it be DEFAULT?) (即使用SCHED_FIFO属性绑定到CPU 0还是默认值?)

Thanks! 谢谢!

You can actually test this with a simple program, but from various man pages: 您可以使用一个简单的程序来测试这个,但是从各种手册页:

sched_setaffinity : sched_setaffinity

A child created via fork(2) inherits its parent's CPU affinity mask. 通过fork(2)创建的子级继承其父级的CPU关联掩码。 The affinity mask is preserved across an execve(2). 关联掩码保留在execve(2)上。

pthread_create : pthread_create

The new thread inherits copies of the calling thread's capability sets (see capabilities(7)) and CPU affinity mask (see sched_setaffinity(2)). 新线程继承调用线程的功能集(请参阅capabilities(7))和CPU亲和力掩码(请参阅sched_setaffinity(2))的副本。

sched_setscheduler : sched_setscheduler

Child processes inherit the scheduling policy and parameters across a fork(2). 子进程在fork(2)中继承调度策略和参数。 The scheduling policy and parameters are preserved across execve(2). 调度策略和参数在execve(2)中保留。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM