Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
200
|
第六章
然而,有時,用戶或應用程式會想要把行程與處理器結合在一起。這是因為行程具有強
烈的快取區敏感性,而且想要停留在相同的處理器上。結合一個行程與一個特定的處理
器,讓核心按照此關係行事,稱為設定一個
硬傾向
hard affinity
)。
sched_getaffinity() sched_setaffinity()
行程會繼承其父行程的 CPU 傾向,預定狀況下,行程可以運行在任何 CPU 之上。Linux
提供了兩個系統呼叫,可用於取得和設定一個行程的「硬傾向」:
#define _GNU_SOURCE
#include <sched.h>
typedef struct cpu_set_t;
size_t CPU_SETSIZE;
void CPU_SET (unsigned long cpu, cpu_set_t *set);
void CPU_CLR (unsigned long cpu, cpu_set_t *set);
int CPU_ISSET (unsigned long cpu, cpu_set_t *set);
void CPU_ZERO (cpu_set_t *set);
int sched_setaffinity (pid_t pid, size_t setsize,
const cpu_set_t *set);
int sched_getaffinity (pid_t pid, size_t setsize,
cpu_set_t *set);
sched_getaffinity() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769812