1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2014-06-08 01:16+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: build/C/man3/CPU_SET.3:27
26 #: build/C/man3/CPU_SET.3:27
32 #: build/C/man3/CPU_SET.3:27 build/C/man2/clone.2:45 build/C/man2/kcmp.2:28 build/C/man2/sched_get_priority_max.2:29 build/C/man3/sched_getcpu.3:26 build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_setaffinity.2:34 build/C/man2/sched_setattr.2:26 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:26 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20 build/C/man7/sched.7:32
38 #: build/C/man3/CPU_SET.3:27 build/C/man2/clone.2:45 build/C/man2/kcmp.2:28 build/C/man2/sched_get_priority_max.2:29 build/C/man3/sched_getcpu.3:26 build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_setaffinity.2:34 build/C/man2/sched_setattr.2:26 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:26 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20 build/C/man7/sched.7:32
40 msgid "Linux Programmer's Manual"
44 #: build/C/man3/CPU_SET.3:28 build/C/man2/clone.2:46 build/C/man2/kcmp.2:29 build/C/man2/sched_get_priority_max.2:30 build/C/man3/sched_getcpu.3:27 build/C/man2/sched_rr_get_interval.2:30 build/C/man2/sched_setaffinity.2:35 build/C/man2/sched_setattr.2:27 build/C/man2/sched_setparam.2:31 build/C/man2/sched_setscheduler.2:27 build/C/man2/sched_yield.2:30 build/C/man2/setns.2:9 build/C/man2/unshare.2:21 build/C/man7/sched.7:33
50 #: build/C/man3/CPU_SET.3:35
52 "CPU_SET, CPU_CLR, CPU_ISSET, CPU_ZERO, CPU_COUNT, CPU_AND, CPU_OR, CPU_XOR, "
53 "CPU_EQUAL, CPU_ALLOC, CPU_ALLOC_SIZE, CPU_FREE, CPU_SET_S, CPU_CLR_S, "
54 "CPU_ISSET_S, CPU_ZERO_S, CPU_COUNT_S, CPU_AND_S, CPU_OR_S, CPU_XOR_S, "
55 "CPU_EQUAL_S - macros for manipulating CPU sets"
59 #: build/C/man3/CPU_SET.3:35 build/C/man2/clone.2:48 build/C/man2/kcmp.2:31 build/C/man2/sched_get_priority_max.2:32 build/C/man3/sched_getcpu.3:29 build/C/man2/sched_rr_get_interval.2:32 build/C/man2/sched_setaffinity.2:38 build/C/man2/sched_setattr.2:30 build/C/man2/sched_setparam.2:33 build/C/man2/sched_setscheduler.2:30 build/C/man2/sched_yield.2:32 build/C/man2/setns.2:11 build/C/man2/unshare.2:23
65 #: build/C/man3/CPU_SET.3:39 build/C/man2/sched_setaffinity.2:42 build/C/man2/setns.2:15
68 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
69 "B<#include E<lt>sched.hE<gt>>\n"
73 #: build/C/man3/CPU_SET.3:41
75 msgid "B<void CPU_ZERO(cpu_set_t *>I<set>B<);>\n"
79 #: build/C/man3/CPU_SET.3:45
82 "B<void CPU_SET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
83 "B<void CPU_CLR(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
84 "B<int CPU_ISSET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
88 #: build/C/man3/CPU_SET.3:47
90 msgid "B<int CPU_COUNT(cpu_set_t *>I<set>B<);>\n"
94 #: build/C/man3/CPU_SET.3:54
97 "B<void CPU_AND(cpu_set_t *>I<destset>B<,>\n"
98 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
99 "B<void CPU_OR(cpu_set_t *>I<destset>B<,>\n"
100 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
101 "B<void CPU_XOR(cpu_set_t *>I<destset>B<,>\n"
102 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
106 #: build/C/man3/CPU_SET.3:56
108 msgid "B<int CPU_EQUAL(cpu_set_t *>I<set1>B<, cpu_set_t *>I<set2>B<);>\n"
112 #: build/C/man3/CPU_SET.3:60
115 "B<cpu_set_t *CPU_ALLOC(int >I<num_cpus>B<);>\n"
116 "B<void CPU_FREE(cpu_set_t *>I<set>B<);>\n"
117 "B<size_t CPU_ALLOC_SIZE(int >I<num_cpus>B<);>\n"
121 #: build/C/man3/CPU_SET.3:62
123 msgid "B<void CPU_ZERO_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
127 #: build/C/man3/CPU_SET.3:66
130 "B<void CPU_SET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
132 "B<void CPU_CLR_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
134 "B<int CPU_ISSET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
139 #: build/C/man3/CPU_SET.3:68
141 msgid "B<int CPU_COUNT_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
145 #: build/C/man3/CPU_SET.3:75
148 "B<void CPU_AND_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
149 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
150 "B<void CPU_OR_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
151 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
152 "B<void CPU_XOR_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
153 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
157 #: build/C/man3/CPU_SET.3:78
160 "B<int CPU_EQUAL_S(size_t >I<setsize>B<, cpu_set_t *>I<set1>B<, cpu_set_t "
165 #: build/C/man3/CPU_SET.3:79 build/C/man2/clone.2:86 build/C/man2/kcmp.2:41 build/C/man2/sched_get_priority_max.2:38 build/C/man3/sched_getcpu.3:55 build/C/man2/sched_rr_get_interval.2:36 build/C/man2/sched_setaffinity.2:49 build/C/man2/sched_setattr.2:41 build/C/man2/sched_setparam.2:47 build/C/man2/sched_setscheduler.2:41 build/C/man2/sched_yield.2:36 build/C/man2/setns.2:18 build/C/man2/unshare.2:50 build/C/man7/sched.7:35
171 #: build/C/man3/CPU_SET.3:86
173 "The I<cpu_set_t> data structure represents a set of CPUs. CPU sets are used "
174 "by B<sched_setaffinity>(2) and similar interfaces."
178 #: build/C/man3/CPU_SET.3:93
180 "The I<cpu_set_t> data type is implemented as a bit set. However, the data "
181 "structure treated as considered opaque: all manipulation of CPU sets should "
182 "be done via the macros described in this page."
186 #: build/C/man3/CPU_SET.3:96
187 msgid "The following macros are provided to operate on the CPU set I<set>:"
191 #: build/C/man3/CPU_SET.3:96
193 msgid "B<CPU_ZERO>()"
197 #: build/C/man3/CPU_SET.3:101
198 msgid "Clears I<set>, so that it contains no CPUs."
202 #: build/C/man3/CPU_SET.3:101
208 #: build/C/man3/CPU_SET.3:107
209 msgid "Add CPU I<cpu> to I<set>."
213 #: build/C/man3/CPU_SET.3:107
219 #: build/C/man3/CPU_SET.3:113
220 msgid "Remove CPU I<cpu> from I<set>."
224 #: build/C/man3/CPU_SET.3:113
226 msgid "B<CPU_ISSET>()"
230 #: build/C/man3/CPU_SET.3:119
231 msgid "Test to see if CPU I<cpu> is a member of I<set>."
235 #: build/C/man3/CPU_SET.3:119
237 msgid "B<CPU_COUNT>()"
241 #: build/C/man3/CPU_SET.3:123
242 msgid "Return the number of CPUs in I<set>."
246 #: build/C/man3/CPU_SET.3:128
248 "Where a I<cpu> argument is specified, it should not produce side effects, "
249 "since the above macros may evaluate the argument more than once."
253 #: build/C/man3/CPU_SET.3:139
255 "The first available CPU on the system corresponds to a I<cpu> value of 0, "
256 "the next CPU corresponds to a I<cpu> value of 1, and so on. The constant "
257 "B<CPU_SETSIZE> (currently 1024) specifies a value one greater than the "
258 "maximum CPU number that can be stored in I<cpu_set_t>."
262 #: build/C/man3/CPU_SET.3:141
263 msgid "The following macros perform logical operations on CPU sets:"
267 #: build/C/man3/CPU_SET.3:141
273 #: build/C/man3/CPU_SET.3:150
275 "Store the intersection of the sets I<srcset1> and I<srcset2> in I<destset> "
276 "(which may be one of the source sets)."
280 #: build/C/man3/CPU_SET.3:150
286 #: build/C/man3/CPU_SET.3:159
288 "Store the union of the sets I<srcset1> and I<srcset2> in I<destset> (which "
289 "may be one of the source sets)."
293 #: build/C/man3/CPU_SET.3:159
299 #: build/C/man3/CPU_SET.3:173
301 "Store the XOR of the sets I<srcset1> and I<srcset2> in I<destset> (which may "
302 "be one of the source sets). The XOR means the set of CPUs that are in "
303 "either I<srcset1> or I<srcset2>, but not both."
307 #: build/C/man3/CPU_SET.3:173
309 msgid "B<CPU_EQUAL>()"
313 #: build/C/man3/CPU_SET.3:176
314 msgid "Test whether two CPU set contain exactly the same CPUs."
318 #: build/C/man3/CPU_SET.3:176
320 msgid "Dynamically sized CPU sets"
324 #: build/C/man3/CPU_SET.3:182
326 "Because some applications may require the ability to dynamically size CPU "
327 "sets (e.g., to allocate sets larger than that defined by the standard "
328 "I<cpu_set_t> data type), glibc nowadays provides a set of macros to support "
333 #: build/C/man3/CPU_SET.3:184
334 msgid "The following macros are used to allocate and deallocate CPU sets:"
338 #: build/C/man3/CPU_SET.3:184
340 msgid "B<CPU_ALLOC>()"
344 #: build/C/man3/CPU_SET.3:189
346 "Allocate a CPU set large enough to hold CPUs in the range 0 to "
351 #: build/C/man3/CPU_SET.3:189
353 msgid "B<CPU_ALLOC_SIZE>()"
357 #: build/C/man3/CPU_SET.3:199
359 "Return the size in bytes of the CPU set that would be needed to hold CPUs in "
360 "the range 0 to I<num_cpus-1>. This macro provides the value that can be "
361 "used for the I<setsize> argument in the B<CPU_*_S>() macros described "
366 #: build/C/man3/CPU_SET.3:199
368 msgid "B<CPU_FREE>()"
372 #: build/C/man3/CPU_SET.3:203
373 msgid "Free a CPU set previously allocated by B<CPU_ALLOC>()."
377 #: build/C/man3/CPU_SET.3:210
379 "The macros whose names end with \"_S\" are the analogs of the similarly "
380 "named macros without the suffix. These macros perform the same tasks as "
381 "their analogs, but operate on the dynamically allocated CPU set(s) whose "
382 "size is I<setsize> bytes."
386 #: build/C/man3/CPU_SET.3:210 build/C/man2/clone.2:878 build/C/man2/kcmp.2:127 build/C/man2/sched_get_priority_max.2:97 build/C/man3/sched_getcpu.3:58 build/C/man2/sched_rr_get_interval.2:73 build/C/man2/sched_setaffinity.2:107 build/C/man2/sched_setattr.2:262 build/C/man2/sched_setparam.2:87 build/C/man2/sched_setscheduler.2:135 build/C/man2/sched_yield.2:41 build/C/man2/setns.2:70 build/C/man2/unshare.2:207
392 #: build/C/man3/CPU_SET.3:219
394 "B<CPU_ISSET>() and B<CPU_ISSET_S>() return nonzero if I<cpu> is in I<set>; "
395 "otherwise, it returns 0."
399 #: build/C/man3/CPU_SET.3:225
400 msgid "B<CPU_COUNT>() and B<CPU_COUNT_S>() return the number of CPUs in I<set>."
404 #: build/C/man3/CPU_SET.3:230
406 "B<CPU_EQUAL>() and B<CPU_EQUAL_S>() return nonzero if the two CPU sets are "
407 "equal; otherwise it returns 0."
411 #: build/C/man3/CPU_SET.3:235
413 "B<CPU_ALLOC>() returns a pointer on success, or NULL on failure. (Errors "
414 "are as for B<malloc>(3).)"
418 #: build/C/man3/CPU_SET.3:239
420 "B<CPU_ALLOC_SIZE>() returns the number of bytes required to store a CPU set "
421 "of the specified cardinality."
425 #: build/C/man3/CPU_SET.3:241
426 msgid "The other functions do not return a value."
430 #: build/C/man3/CPU_SET.3:241 build/C/man2/clone.2:995 build/C/man2/kcmp.2:198 build/C/man3/sched_getcpu.3:70 build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setattr.2:348 build/C/man2/setns.2:97 build/C/man2/unshare.2:224
436 #: build/C/man3/CPU_SET.3:249
438 "The B<CPU_ZERO>(), B<CPU_SET>(), B<CPU_CLR>(), and B<CPU_ISSET>() macros "
439 "were added in glibc 2.3.3."
443 #: build/C/man3/CPU_SET.3:252
444 msgid "B<CPU_COUNT>() first appeared in glibc 2.6."
448 #: build/C/man3/CPU_SET.3:270
450 "B<CPU_AND>(), B<CPU_OR>(), B<CPU_XOR>(), B<CPU_EQUAL>(), B<CPU_ALLOC>(), "
451 "B<CPU_ALLOC_SIZE>(), B<CPU_FREE>(), B<CPU_ZERO_S>(), B<CPU_SET_S>(), "
452 "B<CPU_CLR_S>(), B<CPU_ISSET_S>(), B<CPU_AND_S>(), B<CPU_OR_S>(), "
453 "B<CPU_XOR_S>(), and B<CPU_EQUAL_S>() first appeared in glibc 2.7."
457 #: build/C/man3/CPU_SET.3:270 build/C/man2/clone.2:1002 build/C/man2/kcmp.2:202 build/C/man2/sched_get_priority_max.2:113 build/C/man3/sched_getcpu.3:77 build/C/man2/sched_rr_get_interval.2:94 build/C/man2/sched_setaffinity.2:159 build/C/man2/sched_setattr.2:351 build/C/man2/sched_setparam.2:119 build/C/man2/sched_setscheduler.2:170 build/C/man2/sched_yield.2:52 build/C/man2/setns.2:102 build/C/man2/unshare.2:228
459 msgid "CONFORMING TO"
463 #: build/C/man3/CPU_SET.3:272
464 msgid "These interfaces are Linux-specific."
468 #: build/C/man3/CPU_SET.3:272 build/C/man2/clone.2:1006 build/C/man2/kcmp.2:205 build/C/man3/sched_getcpu.3:80 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setaffinity.2:161 build/C/man2/sched_setattr.2:353 build/C/man2/sched_setparam.2:121 build/C/man2/sched_setscheduler.2:173 build/C/man2/sched_yield.2:54 build/C/man2/setns.2:106 build/C/man2/unshare.2:232 build/C/man7/sched.7:612
474 #: build/C/man3/CPU_SET.3:275
475 msgid "To duplicate a CPU set, use B<memcpy>(3)."
479 #: build/C/man3/CPU_SET.3:282
481 "Since CPU sets are bit sets allocated in units of long words, the actual "
482 "number of CPUs in a dynamically allocated CPU set will be rounded up to the "
483 "next multiple of I<sizeof(unsigned long)>. An application should consider "
484 "the contents of these extra bits to be undefined."
488 #: build/C/man3/CPU_SET.3:294
490 "Notwithstanding the similarity in the names, note that the constant "
491 "B<CPU_SETSIZE> indicates the number of CPUs in the I<cpu_set_t> data type "
492 "(thus, it is effectively a count of bits in the bit set), while the "
493 "I<setsize> argument of the B<CPU_*_S>() macros is a size in bytes."
497 #: build/C/man3/CPU_SET.3:300
499 "The data types for arguments and return values shown in the SYNOPSIS are "
500 "hints what about is expected in each case. However, since these interfaces "
501 "are implemented as macros, the compiler won't necessarily catch all type "
502 "errors if you violate the suggestions."
506 #: build/C/man3/CPU_SET.3:300 build/C/man2/clone.2:1031 build/C/man2/sched_setattr.2:369 build/C/man2/sched_setscheduler.2:214
511 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7029
513 #: build/C/man3/CPU_SET.3:312
515 "On 32-bit platforms with glibc 2.8 and earlier, B<CPU_ALLOC>() allocates "
516 "twice as much space as is required, and B<CPU_ALLOC_SIZE>() returns a value "
517 "twice as large as it should. This bug should not affect the semantics of a "
518 "program, but does result in wasted memory and less efficient operation of "
519 "the macros that operate on dynamically allocated CPU sets. These bugs are "
520 "fixed in glibc 2.9."
524 #: build/C/man3/CPU_SET.3:312 build/C/man2/clone.2:1073 build/C/man2/setns.2:112
530 #: build/C/man3/CPU_SET.3:315
532 "The following program demonstrates the use of some of the macros used for "
533 "dynamically allocated CPU sets."
537 #: build/C/man3/CPU_SET.3:323
540 "#define _GNU_SOURCE\n"
541 "#include E<lt>sched.hE<gt>\n"
542 "#include E<lt>stdlib.hE<gt>\n"
543 "#include E<lt>unistd.hE<gt>\n"
544 "#include E<lt>stdio.hE<gt>\n"
545 "#include E<lt>assert.hE<gt>\n"
549 #: build/C/man3/CPU_SET.3:330
553 "main(int argc, char *argv[])\n"
555 " cpu_set_t *cpusetp;\n"
557 " int num_cpus, cpu;\n"
561 #: build/C/man3/CPU_SET.3:335
564 " if (argc E<lt> 2) {\n"
565 " fprintf(stderr, \"Usage: %s E<lt>num-cpusE<gt>\\en\", argv[0]);\n"
566 " exit(EXIT_FAILURE);\n"
571 #: build/C/man3/CPU_SET.3:337
573 msgid " num_cpus = atoi(argv[1]);\n"
577 #: build/C/man3/CPU_SET.3:343
580 " cpusetp = CPU_ALLOC(num_cpus);\n"
581 " if (cpusetp == NULL) {\n"
582 " perror(\"CPU_ALLOC\");\n"
583 " exit(EXIT_FAILURE);\n"
588 #: build/C/man3/CPU_SET.3:345
590 msgid " size = CPU_ALLOC_SIZE(num_cpus);\n"
594 #: build/C/man3/CPU_SET.3:349
597 " CPU_ZERO_S(size, cpusetp);\n"
598 " for (cpu = 0; cpu E<lt> num_cpus; cpu += 2)\n"
599 " CPU_SET_S(cpu, size, cpusetp);\n"
603 #: build/C/man3/CPU_SET.3:351
605 msgid " printf(\"CPU_COUNT() of set: %d\\en\", CPU_COUNT_S(size, cpusetp));\n"
609 #: build/C/man3/CPU_SET.3:355
612 " CPU_FREE(cpusetp);\n"
613 " exit(EXIT_SUCCESS);\n"
618 #: build/C/man3/CPU_SET.3:356 build/C/man2/clone.2:1170 build/C/man2/kcmp.2:222 build/C/man2/sched_get_priority_max.2:115 build/C/man3/sched_getcpu.3:100 build/C/man2/sched_rr_get_interval.2:132 build/C/man2/sched_setaffinity.2:214 build/C/man2/sched_setattr.2:385 build/C/man2/sched_setparam.2:127 build/C/man2/sched_setscheduler.2:222 build/C/man2/sched_yield.2:79 build/C/man2/setns.2:199 build/C/man2/unshare.2:266 build/C/man7/sched.7:665
624 #: build/C/man3/CPU_SET.3:361
626 "B<sched_setaffinity>(2), B<pthread_attr_setaffinity_np>(3), "
627 "B<pthread_setaffinity_np>(3), B<cpuset>(7)"
631 #: build/C/man3/CPU_SET.3:361 build/C/man2/clone.2:1184 build/C/man2/kcmp.2:225 build/C/man2/sched_get_priority_max.2:125 build/C/man3/sched_getcpu.3:103 build/C/man2/sched_rr_get_interval.2:134 build/C/man2/sched_setaffinity.2:234 build/C/man2/sched_setattr.2:407 build/C/man2/sched_setparam.2:142 build/C/man2/sched_setscheduler.2:241 build/C/man2/sched_yield.2:81 build/C/man2/setns.2:205 build/C/man2/unshare.2:275 build/C/man7/sched.7:702
637 #: build/C/man3/CPU_SET.3:369 build/C/man2/clone.2:1192 build/C/man2/kcmp.2:233 build/C/man2/sched_get_priority_max.2:133 build/C/man3/sched_getcpu.3:111 build/C/man2/sched_rr_get_interval.2:142 build/C/man2/sched_setaffinity.2:242 build/C/man2/sched_setattr.2:415 build/C/man2/sched_setparam.2:150 build/C/man2/sched_setscheduler.2:249 build/C/man2/sched_yield.2:89 build/C/man2/setns.2:213 build/C/man2/unshare.2:283 build/C/man7/sched.7:710
639 "This page is part of release 3.67 of the Linux I<man-pages> project. A "
640 "description of the project, information about reporting bugs, and the latest "
641 "version of this page, can be found at "
642 "\\%http://www.kernel.org/doc/man-pages/."
646 #: build/C/man2/clone.2:45
652 #: build/C/man2/clone.2:45
658 #: build/C/man2/clone.2:48
659 msgid "clone, __clone2 - create a child process"
663 #: build/C/man2/clone.2:51
665 msgid "/* Prototype for the glibc wrapper function */\n"
669 #: build/C/man2/clone.2:53 build/C/man3/sched_getcpu.3:32 build/C/man2/sched_setattr.2:33 build/C/man2/sched_setparam.2:36 build/C/man2/sched_setscheduler.2:33 build/C/man2/unshare.2:26
671 msgid "B<#include E<lt>sched.hE<gt>>\n"
675 #: build/C/man2/clone.2:58
678 "B<int clone(int (*>I<fn>B<)(void *), void *>I<child_stack>B<,>\n"
679 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
680 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
681 "*>I<ctid>B< */ );>\n"
685 #: build/C/man2/clone.2:60
687 msgid "/* Prototype for the raw system call */\n"
691 #: build/C/man2/clone.2:64
694 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
695 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
696 "B< struct pt_regs *>I<regs>B<);>\n"
700 #: build/C/man2/clone.2:69
702 "Feature Test Macro Requirements for glibc wrapper function (see "
703 "B<feature_test_macros>(7)):"
707 #: build/C/man2/clone.2:72
712 #: build/C/man2/clone.2:75 build/C/man3/sched_getcpu.3:45 build/C/man2/unshare.2:39
714 msgid "Since glibc 2.14:"
718 #: build/C/man2/clone.2:78 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
722 #. See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
724 #: build/C/man2/clone.2:78 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
726 msgid "Before glibc 2.14:"
730 #: build/C/man2/clone.2:83 build/C/man3/sched_getcpu.3:52 build/C/man2/unshare.2:47
733 "_BSD_SOURCE || _SVID_SOURCE\n"
734 " /* _GNU_SOURCE also suffices */\n"
738 #: build/C/man2/clone.2:90
739 msgid "B<clone>() creates a new process, in a manner similar to B<fork>(2)."
743 #: build/C/man2/clone.2:97
745 "This page describes both the glibc B<clone>() wrapper function and the "
746 "underlying system call on which it is based. The main text describes the "
747 "wrapper function; the differences for the raw system call are described "
748 "toward the end of this page."
752 #: build/C/man2/clone.2:109
754 "Unlike B<fork>(2), B<clone>() allows the child process to share parts of "
755 "its execution context with the calling process, such as the memory space, "
756 "the table of file descriptors, and the table of signal handlers. (Note that "
757 "on this manual page, \"calling process\" normally corresponds to \"parent "
758 "process\". But see the description of B<CLONE_PARENT> below.)"
762 #: build/C/man2/clone.2:114
764 "The main use of B<clone>() is to implement threads: multiple threads of "
765 "control in a program that run concurrently in a shared memory space."
769 #: build/C/man2/clone.2:134
771 "When the child process is created with B<clone>(), it executes the function "
772 "I<fn>(I<arg>). (This differs from B<fork>(2), where execution continues in "
773 "the child from the point of the B<fork>(2) call.) The I<fn> argument is a "
774 "pointer to a function that is called by the child process at the beginning "
775 "of its execution. The I<arg> argument is passed to the I<fn> function."
779 #: build/C/man2/clone.2:144
781 "When the I<fn>(I<arg>) function application returns, the child process "
782 "terminates. The integer returned by I<fn> is the exit code for the child "
783 "process. The child process may also terminate explicitly by calling "
784 "B<exit>(2) or after receiving a fatal signal."
788 #: build/C/man2/clone.2:160
790 "The I<child_stack> argument specifies the location of the stack used by the "
791 "child process. Since the child and calling process may share memory, it is "
792 "not possible for the child process to execute in the same stack as the "
793 "calling process. The calling process must therefore set up memory space for "
794 "the child stack and pass a pointer to this space to B<clone>(). Stacks grow "
795 "downward on all processors that run Linux (except the HP PA processors), so "
796 "I<child_stack> usually points to the topmost address of the memory space set "
797 "up for the child stack."
801 #: build/C/man2/clone.2:176
803 "The low byte of I<flags> contains the number of the I<termination signal> "
804 "sent to the parent when the child dies. If this signal is specified as "
805 "anything other than B<SIGCHLD>, then the parent process must specify the "
806 "B<__WALL> or B<__WCLONE> options when waiting for the child with "
807 "B<wait>(2). If no signal is specified, then the parent process is not "
808 "signaled when the child terminates."
812 #: build/C/man2/clone.2:181
814 "I<flags> may also be bitwise-or'ed with zero or more of the following "
815 "constants, in order to specify what is shared between the calling process "
816 "and the child process:"
820 #: build/C/man2/clone.2:181
822 msgid "B<CLONE_CHILD_CLEARTID> (since Linux 2.5.49)"
826 #: build/C/man2/clone.2:191
828 "Erase child thread ID at location I<ctid> in child memory when the child "
829 "exits, and do a wakeup on the futex at that address. The address involved "
830 "may be changed by the B<set_tid_address>(2) system call. This is used by "
831 "threading libraries."
835 #: build/C/man2/clone.2:191
837 msgid "B<CLONE_CHILD_SETTID> (since Linux 2.5.49)"
841 #: build/C/man2/clone.2:196
842 msgid "Store child thread ID at location I<ctid> in child memory."
846 #: build/C/man2/clone.2:196
848 msgid "B<CLONE_FILES> (since Linux 2.0)"
852 #: build/C/man2/clone.2:209
854 "If B<CLONE_FILES> is set, the calling process and the child process share "
855 "the same file descriptor table. Any file descriptor created by the calling "
856 "process or by the child process is also valid in the other process. "
857 "Similarly, if one of the processes closes a file descriptor, or changes its "
858 "associated flags (using the B<fcntl>(2) B<F_SETFD> operation), the other "
859 "process is also affected."
863 #: build/C/man2/clone.2:223
865 "If B<CLONE_FILES> is not set, the child process inherits a copy of all file "
866 "descriptors opened in the calling process at the time of B<clone>(). (The "
867 "duplicated file descriptors in the child refer to the same open file "
868 "descriptions (see B<open>(2)) as the corresponding file descriptors in the "
869 "calling process.) Subsequent operations that open or close file "
870 "descriptors, or change file descriptor flags, performed by either the "
871 "calling process or the child process do not affect the other process."
875 #: build/C/man2/clone.2:223
877 msgid "B<CLONE_FS> (since Linux 2.0)"
881 #: build/C/man2/clone.2:238
883 "If B<CLONE_FS> is set, the caller and the child process share the same "
884 "filesystem information. This includes the root of the filesystem, the "
885 "current working directory, and the umask. Any call to B<chroot>(2), "
886 "B<chdir>(2), or B<umask>(2) performed by the calling process or the child "
887 "process also affects the other process."
891 #: build/C/man2/clone.2:250
893 "If B<CLONE_FS> is not set, the child process works on a copy of the "
894 "filesystem information of the calling process at the time of the B<clone>() "
895 "call. Calls to B<chroot>(2), B<chdir>(2), B<umask>(2) performed later by "
896 "one of the processes do not affect the other process."
900 #: build/C/man2/clone.2:250
902 msgid "B<CLONE_IO> (since Linux 2.6.25)"
906 #: build/C/man2/clone.2:259
908 "If B<CLONE_IO> is set, then the new process shares an I/O context with the "
909 "calling process. If this flag is not set, then (as with B<fork>(2)) the "
910 "new process has its own I/O context."
913 #. The following based on text from Jens Axboe
914 #. the anticipatory and CFQ scheduler
917 #: build/C/man2/clone.2:276
919 "The I/O context is the I/O scope of the disk scheduler (i.e, what the I/O "
920 "scheduler uses to model scheduling of a process's I/O). If processes share "
921 "the same I/O context, they are treated as one by the I/O scheduler. As a "
922 "consequence, they get to share disk time. For some I/O schedulers, if two "
923 "processes share an I/O context, they will be allowed to interleave their "
924 "disk access. If several threads are doing I/O on behalf of the same process "
925 "(B<aio_read>(3), for instance), they should employ B<CLONE_IO> to get better "
930 #: build/C/man2/clone.2:280
932 "If the kernel is not configured with the B<CONFIG_BLOCK> option, this flag "
937 #: build/C/man2/clone.2:280 build/C/man2/unshare.2:96
939 msgid "B<CLONE_NEWIPC> (since Linux 2.6.19)"
943 #: build/C/man2/clone.2:290
945 "If B<CLONE_NEWIPC> is set, then create the process in a new IPC namespace. "
946 "If this flag is not set, then (as with B<fork>(2)), the process is created "
947 "in the same IPC namespace as the calling process. This flag is intended for "
948 "the implementation of containers."
951 #. commit 7eafd7c74c3f2e67c27621b987b28397110d643f
952 #. https://lwn.net/Articles/312232/
954 #: build/C/man2/clone.2:302
956 "An IPC namespace provides an isolated view of System\\ V IPC objects (see "
957 "B<svipc>(7)) and (since Linux 2.6.30) POSIX message queues (see "
958 "B<mq_overview>(7)). The common characteristic of these IPC mechanisms is "
959 "that IPC objects are identified by mechanisms other than filesystem "
964 #: build/C/man2/clone.2:306
966 "Objects created in an IPC namespace are visible to all other processes that "
967 "are members of that namespace, but are not visible to processes in other IPC "
972 #: build/C/man2/clone.2:310
974 "When an IPC namespace is destroyed (i.e., when the last process that is a "
975 "member of the namespace terminates), all IPC objects in the namespace are "
976 "automatically destroyed."
980 #: build/C/man2/clone.2:319
982 "Use of this flag requires: a kernel configured with the B<CONFIG_SYSVIPC> "
983 "and B<CONFIG_IPC_NS> options and that the process be privileged "
984 "(B<CAP_SYS_ADMIN>). This flag can't be specified in conjunction with "
989 #: build/C/man2/clone.2:319 build/C/man2/unshare.2:113
991 msgid "B<CLONE_NEWNET> (since Linux 2.6.24)"
994 #. FIXME Check when the implementation was completed
996 #: build/C/man2/clone.2:324
998 "(The implementation of this flag was completed only by about kernel version "
1003 #: build/C/man2/clone.2:333
1005 "If B<CLONE_NEWNET> is set, then create the process in a new network "
1006 "namespace. If this flag is not set, then (as with B<fork>(2)), the process "
1007 "is created in the same network namespace as the calling process. This flag "
1008 "is intended for the implementation of containers."
1011 #. FIXME Add pointer to veth(4) page when it is eventually completed
1013 #: build/C/man2/clone.2:348
1015 "A network namespace provides an isolated view of the networking stack "
1016 "(network device interfaces, IPv4 and IPv6 protocol stacks, IP routing "
1017 "tables, firewall rules, the I</proc/net> and I</sys/class/net> directory "
1018 "trees, sockets, etc.). A physical network device can live in exactly one "
1019 "network namespace. A virtual network device (\"veth\") pair provides a "
1020 "pipe-like abstraction that can be used to create tunnels between network "
1021 "namespaces, and can be used to create a bridge to a physical network device "
1022 "in another namespace."
1026 #: build/C/man2/clone.2:353
1028 "When a network namespace is freed (i.e., when the last process in the "
1029 "namespace terminates), its physical network devices are moved back to the "
1030 "initial network namespace (not to the parent of the process)."
1034 #: build/C/man2/clone.2:358
1036 "Use of this flag requires: a kernel configured with the B<CONFIG_NET_NS> "
1037 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
1041 #: build/C/man2/clone.2:358
1043 msgid "B<CLONE_NEWNS> (since Linux 2.4.19)"
1047 #: build/C/man2/clone.2:361
1048 msgid "Start the child in a new mount namespace."
1052 #: build/C/man2/clone.2:382
1054 "Every process lives in a mount namespace. The I<namespace> of a process is "
1055 "the data (the set of mounts) describing the file hierarchy as seen by that "
1056 "process. After a B<fork>(2) or B<clone>() where the B<CLONE_NEWNS> flag "
1057 "is not set, the child lives in the same mount namespace as the parent. The "
1058 "system calls B<mount>(2) and B<umount>(2) change the mount namespace of "
1059 "the calling process, and hence affect all processes that live in the same "
1060 "namespace, but do not affect processes in a different mount namespace."
1064 #: build/C/man2/clone.2:389
1066 "After a B<clone>() where the B<CLONE_NEWNS> flag is set, the cloned child "
1067 "is started in a new mount namespace, initialized with a copy of the "
1068 "namespace of the parent."
1072 #: build/C/man2/clone.2:401
1074 "Only a privileged process (one having the B<CAP_SYS_ADMIN> capability) may "
1075 "specify the B<CLONE_NEWNS> flag. It is not permitted to specify both "
1076 "B<CLONE_NEWNS> and B<CLONE_FS> in the same B<clone>() call."
1080 #: build/C/man2/clone.2:401
1082 msgid "B<CLONE_NEWPID> (since Linux 2.6.24)"
1085 #. This explanation draws a lot of details from
1086 #. http://lwn.net/Articles/259217/
1087 #. Authors: Pavel Emelyanov <xemul@openvz.org>
1088 #. and Kir Kolyshkin <kir@openvz.org>
1090 #. The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
1091 #. Author: Pavel Emelyanov <xemul@openvz.org>
1093 #: build/C/man2/clone.2:418
1095 "If B<CLONE_NEWPID> is set, then create the process in a new PID namespace. "
1096 "If this flag is not set, then (as with B<fork>(2)), the process is created "
1097 "in the same PID namespace as the calling process. This flag is intended for "
1098 "the implementation of containers."
1102 #: build/C/man2/clone.2:427
1104 "A PID namespace provides an isolated environment for PIDs: PIDs in a new "
1105 "namespace start at 1, somewhat like a standalone system, and calls to "
1106 "B<fork>(2), B<vfork>(2), or B<clone>() will produce processes with PIDs "
1107 "that are unique within the namespace."
1111 #: build/C/man2/clone.2:439
1113 "The first process created in a new namespace (i.e., the process created "
1114 "using the B<CLONE_NEWPID> flag) has the PID 1, and is the \"init\" process "
1115 "for the namespace. Children that are orphaned within the namespace will be "
1116 "reparented to this process rather than B<init>(8). Unlike the traditional "
1117 "B<init> process, the \"init\" process of a PID namespace can terminate, and "
1118 "if it does, all of the processes in the namespace are terminated."
1122 #: build/C/man2/clone.2:458
1124 "PID namespaces form a hierarchy. When a new PID namespace is created, the "
1125 "processes in that namespace are visible in the PID namespace of the process "
1126 "that created the new namespace; analogously, if the parent PID namespace is "
1127 "itself the child of another PID namespace, then processes in the child and "
1128 "parent PID namespaces will both be visible in the grandparent PID "
1129 "namespace. Conversely, the processes in the \"child\" PID namespace do not "
1130 "see the processes in the parent namespace. The existence of a namespace "
1131 "hierarchy means that each process may now have multiple PIDs: one for each "
1132 "namespace in which it is visible; each of these PIDs is unique within the "
1133 "corresponding namespace. (A call to B<getpid>(2) always returns the PID "
1134 "associated with the namespace in which the process lives.)"
1137 #. mount -t proc proc /proc
1139 #: build/C/man2/clone.2:474
1141 "After creating the new namespace, it is useful for the child to change its "
1142 "root directory and mount a new procfs instance at I</proc> so that tools "
1143 "such as B<ps>(1) work correctly. (If B<CLONE_NEWNS> is also included in "
1144 "I<flags>, then it isn't necessary to change the root directory: a new procfs "
1145 "instance can be mounted directly over I</proc>.)"
1149 #: build/C/man2/clone.2:481
1151 "Use of this flag requires: a kernel configured with the B<CONFIG_PID_NS> "
1152 "option and that the process be privileged (B<CAP_SYS_ADMIN>). This flag "
1153 "can't be specified in conjunction with B<CLONE_THREAD>."
1157 #: build/C/man2/clone.2:481 build/C/man2/unshare.2:149
1159 msgid "B<CLONE_NEWUTS> (since Linux 2.6.19)"
1163 #: build/C/man2/clone.2:493
1165 "If B<CLONE_NEWUTS> is set, then create the process in a new UTS namespace, "
1166 "whose identifiers are initialized by duplicating the identifiers from the "
1167 "UTS namespace of the calling process. If this flag is not set, then (as "
1168 "with B<fork>(2)), the process is created in the same UTS namespace as the "
1169 "calling process. This flag is intended for the implementation of "
1174 #: build/C/man2/clone.2:504
1176 "A UTS namespace is the set of identifiers returned by B<uname>(2); among "
1177 "these, the domain name and the hostname can be modified by "
1178 "B<setdomainname>(2) and B<sethostname>(2), respectively. Changes made to "
1179 "the identifiers in a UTS namespace are visible to all other processes in the "
1180 "same namespace, but are not visible to processes in other UTS namespaces."
1184 #: build/C/man2/clone.2:509
1186 "Use of this flag requires: a kernel configured with the B<CONFIG_UTS_NS> "
1187 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
1191 #: build/C/man2/clone.2:509
1193 msgid "B<CLONE_PARENT> (since Linux 2.3.12)"
1197 #: build/C/man2/clone.2:516
1199 "If B<CLONE_PARENT> is set, then the parent of the new child (as returned by "
1200 "B<getppid>(2)) will be the same as that of the calling process."
1204 #: build/C/man2/clone.2:522
1206 "If B<CLONE_PARENT> is not set, then (as with B<fork>(2)) the child's parent "
1207 "is the calling process."
1211 #: build/C/man2/clone.2:530
1213 "Note that it is the parent process, as returned by B<getppid>(2), which is "
1214 "signaled when the child terminates, so that if B<CLONE_PARENT> is set, then "
1215 "the parent of the calling process, rather than the calling process itself, "
1220 #: build/C/man2/clone.2:530
1222 msgid "B<CLONE_PARENT_SETTID> (since Linux 2.5.49)"
1226 #: build/C/man2/clone.2:538
1228 "Store child thread ID at location I<ptid> in parent and child memory. (In "
1229 "Linux 2.5.32-2.5.48 there was a flag B<CLONE_SETTID> that did this.)"
1233 #: build/C/man2/clone.2:538
1235 msgid "B<CLONE_PID> (obsolete)"
1239 #: build/C/man2/clone.2:549
1241 "If B<CLONE_PID> is set, the child process is created with the same process "
1242 "ID as the calling process. This is good for hacking the system, but "
1243 "otherwise of not much use. Since 2.3.21 this flag can be specified only by "
1244 "the system boot process (PID 0). It disappeared in Linux 2.5.16."
1248 #: build/C/man2/clone.2:549
1250 msgid "B<CLONE_PTRACE> (since Linux 2.2)"
1254 #: build/C/man2/clone.2:556
1256 "If B<CLONE_PTRACE> is specified, and the calling process is being traced, "
1257 "then trace the child also (see B<ptrace>(2))."
1261 #: build/C/man2/clone.2:556
1263 msgid "B<CLONE_SETTLS> (since Linux 2.5.32)"
1267 #: build/C/man2/clone.2:563
1269 "The I<newtls> argument is the new TLS (Thread Local Storage) descriptor. "
1270 "(See B<set_thread_area>(2).)"
1274 #: build/C/man2/clone.2:563
1276 msgid "B<CLONE_SIGHAND> (since Linux 2.0)"
1280 #: build/C/man2/clone.2:579
1282 "If B<CLONE_SIGHAND> is set, the calling process and the child process share "
1283 "the same table of signal handlers. If the calling process or child process "
1284 "calls B<sigaction>(2) to change the behavior associated with a signal, the "
1285 "behavior is changed in the other process as well. However, the calling "
1286 "process and child processes still have distinct signal masks and sets of "
1287 "pending signals. So, one of them may block or unblock some signals using "
1288 "B<sigprocmask>(2) without affecting the other process."
1292 #: build/C/man2/clone.2:590
1294 "If B<CLONE_SIGHAND> is not set, the child process inherits a copy of the "
1295 "signal handlers of the calling process at the time B<clone>() is called. "
1296 "Calls to B<sigaction>(2) performed later by one of the processes have no "
1297 "effect on the other process."
1301 #: build/C/man2/clone.2:598
1303 "Since Linux 2.6.0-test6, I<flags> must also include B<CLONE_VM> if "
1304 "B<CLONE_SIGHAND> is specified"
1308 #: build/C/man2/clone.2:598
1310 msgid "B<CLONE_STOPPED> (since Linux 2.6.0-test2)"
1314 #: build/C/man2/clone.2:607
1316 "If B<CLONE_STOPPED> is set, then the child is initially stopped (as though "
1317 "it was sent a B<SIGSTOP> signal), and must be resumed by sending it a "
1318 "B<SIGCONT> signal."
1321 #. glibc 2.8 removed this defn from bits/sched.h
1323 #: build/C/man2/clone.2:615
1325 "This flag was I<deprecated> from Linux 2.6.25 onward, and was I<removed> "
1326 "altogether in Linux 2.6.38."
1330 #: build/C/man2/clone.2:615
1332 msgid "B<CLONE_SYSVSEM> (since Linux 2.5.10)"
1336 #: build/C/man2/clone.2:624
1338 "If B<CLONE_SYSVSEM> is set, then the child and the calling process share a "
1339 "single list of System\\ V semaphore undo values (see B<semop>(2)). If this "
1340 "flag is not set, then the child has a separate undo list, which is initially "
1345 #: build/C/man2/clone.2:624
1347 msgid "B<CLONE_THREAD> (since Linux 2.4.0-test8)"
1351 #: build/C/man2/clone.2:633
1353 "If B<CLONE_THREAD> is set, the child is placed in the same thread group as "
1354 "the calling process. To make the remainder of the discussion of "
1355 "B<CLONE_THREAD> more readable, the term \"thread\" is used to refer to the "
1356 "processes within a thread group."
1360 #: build/C/man2/clone.2:641
1362 "Thread groups were a feature added in Linux 2.4 to support the POSIX threads "
1363 "notion of a set of threads that share a single PID. Internally, this shared "
1364 "PID is the so-called thread group identifier (TGID) for the thread group. "
1365 "Since Linux 2.4, calls to B<getpid>(2) return the TGID of the caller."
1369 #: build/C/man2/clone.2:650
1371 "The threads within a group can be distinguished by their (system-wide) "
1372 "unique thread IDs (TID). A new thread's TID is available as the function "
1373 "result returned to the caller of B<clone>(), and a thread can obtain its own "
1374 "TID using B<gettid>(2)."
1378 #: build/C/man2/clone.2:660
1380 "When a call is made to B<clone>() without specifying B<CLONE_THREAD>, then "
1381 "the resulting thread is placed in a new thread group whose TGID is the same "
1382 "as the thread's TID. This thread is the I<leader> of the new thread group."
1386 #: build/C/man2/clone.2:682
1388 "A new thread created with B<CLONE_THREAD> has the same parent process as the "
1389 "caller of B<clone>() (i.e., like B<CLONE_PARENT>), so that calls to "
1390 "B<getppid>(2) return the same value for all of the threads in a thread "
1391 "group. When a B<CLONE_THREAD> thread terminates, the thread that created it "
1392 "using B<clone>() is not sent a B<SIGCHLD> (or other termination) signal; "
1393 "nor can the status of such a thread be obtained using B<wait>(2). (The "
1394 "thread is said to be I<detached>.)"
1398 #: build/C/man2/clone.2:687
1400 "After all of the threads in a thread group terminate the parent process of "
1401 "the thread group is sent a B<SIGCHLD> (or other termination) signal."
1405 #: build/C/man2/clone.2:692
1407 "If any of the threads in a thread group performs an B<execve>(2), then all "
1408 "threads other than the thread group leader are terminated, and the new "
1409 "program is executed in the thread group leader."
1413 #: build/C/man2/clone.2:698
1415 "If one of the threads in a thread group creates a child using B<fork>(2), "
1416 "then any thread in the group can B<wait>(2) for that child."
1420 #: build/C/man2/clone.2:711
1422 "Since Linux 2.5.35, I<flags> must also include B<CLONE_SIGHAND> if "
1423 "B<CLONE_THREAD> is specified (and note that, since Linux 2.6.0-test6, "
1424 "B<CLONE_SIGHAND> also requires B<CLONE_VM> to be included)."
1428 #: build/C/man2/clone.2:716
1430 "Signals may be sent to a thread group as a whole (i.e., a TGID) using "
1431 "B<kill>(2), or to a specific thread (i.e., TID) using B<tgkill>(2)."
1435 #: build/C/man2/clone.2:721
1437 "Signal dispositions and actions are process-wide: if an unhandled signal is "
1438 "delivered to a thread, then it will affect (terminate, stop, continue, be "
1439 "ignored in) all members of the thread group."
1443 #: build/C/man2/clone.2:734
1445 "Each thread has its own signal mask, as set by B<sigprocmask>(2), but "
1446 "signals can be pending either: for the whole process (i.e., deliverable to "
1447 "any member of the thread group), when sent with B<kill>(2); or for an "
1448 "individual thread, when sent with B<tgkill>(2). A call to B<sigpending>(2) "
1449 "returns a signal set that is the union of the signals pending for the whole "
1450 "process and the signals that are pending for the calling thread."
1454 #: build/C/man2/clone.2:746
1456 "If B<kill>(2) is used to send a signal to a thread group, and the thread "
1457 "group has installed a handler for the signal, then the handler will be "
1458 "invoked in exactly one, arbitrarily selected member of the thread group that "
1459 "has not blocked the signal. If multiple threads in a group are waiting to "
1460 "accept the same signal using B<sigwaitinfo>(2), the kernel will arbitrarily "
1461 "select one of these threads to receive a signal sent using B<kill>(2)."
1465 #: build/C/man2/clone.2:746
1467 msgid "B<CLONE_UNTRACED> (since Linux 2.5.46)"
1471 #: build/C/man2/clone.2:753
1473 "If B<CLONE_UNTRACED> is specified, then a tracing process cannot force "
1474 "B<CLONE_PTRACE> on this child process."
1478 #: build/C/man2/clone.2:753
1480 msgid "B<CLONE_VFORK> (since Linux 2.2)"
1484 #: build/C/man2/clone.2:765
1486 "If B<CLONE_VFORK> is set, the execution of the calling process is suspended "
1487 "until the child releases its virtual memory resources via a call to "
1488 "B<execve>(2) or B<_exit>(2) (as with B<vfork>(2))."
1492 #: build/C/man2/clone.2:771
1494 "If B<CLONE_VFORK> is not set, then both the calling process and the child "
1495 "are schedulable after the call, and an application should not rely on "
1496 "execution occurring in any particular order."
1500 #: build/C/man2/clone.2:771
1502 msgid "B<CLONE_VM> (since Linux 2.0)"
1506 #: build/C/man2/clone.2:784
1508 "If B<CLONE_VM> is set, the calling process and the child process run in the "
1509 "same memory space. In particular, memory writes performed by the calling "
1510 "process or by the child process are also visible in the other process. "
1511 "Moreover, any memory mapping or unmapping performed with B<mmap>(2) or "
1512 "B<munmap>(2) by the child or calling process also affects the other "
1517 #: build/C/man2/clone.2:793
1519 "If B<CLONE_VM> is not set, the child process runs in a separate copy of the "
1520 "memory space of the calling process at the time of B<clone>(). Memory "
1521 "writes or file mappings/unmappings performed by one of the processes do not "
1522 "affect the other, as with B<fork>(2)."
1526 #: build/C/man2/clone.2:793
1528 msgid "The raw system call interface"
1532 #: build/C/man2/clone.2:809
1534 "The raw B<clone>() system call corresponds more closely to B<fork>(2) in "
1535 "that execution in the child continues from the point of the call. As such, "
1536 "the I<fn> and I<arg> arguments of the B<clone>() wrapper function are "
1537 "omitted. Furthermore, the argument order changes. The raw system call "
1538 "interface on x86 and many other architectures is roughly:"
1542 #: build/C/man2/clone.2:815
1545 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
1546 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
1547 "B< struct pt_regs *>I<regs>B<);>\n"
1551 #: build/C/man2/clone.2:826
1553 "Another difference for the raw system call is that the I<child_stack> "
1554 "argument may be zero, in which case copy-on-write semantics ensure that the "
1555 "child gets separate copies of stack pages when either process modifies the "
1556 "stack. In this case, for correct operation, the B<CLONE_VM> option should "
1561 #: build/C/man2/clone.2:834
1563 "For some architectures, the order of the arguments for the system call "
1564 "differs from that shown above. On the score, microblaze, ARM, ARM 64, "
1565 "PA-RISC, arc, Power PC, xtensa, and MIPS architectures, the order of the "
1566 "fourth and fifth arguments is reversed. On the cris and s390 architectures, "
1567 "the order of the first and second arguments is reversed."
1571 #: build/C/man2/clone.2:834
1573 msgid "blackfin, m68k, and sparc"
1577 #: build/C/man2/clone.2:838
1579 "The argument-passing conventions on blackfin, m68k, and sparc are different "
1580 "from the descriptions above. For details, see the kernel (and glibc) "
1585 #: build/C/man2/clone.2:838
1591 #: build/C/man2/clone.2:840
1592 msgid "On ia64, a different interface is used:"
1596 #: build/C/man2/clone.2:847
1599 "B<int __clone2(int (*>I<fn>B<)(void *), >\n"
1600 "B< void *>I<child_stack_base>B<, size_t >I<stack_size>B<,>\n"
1601 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
1602 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
1603 "*>I<ctid>B< */ );>\n"
1607 #: build/C/man2/clone.2:859
1609 "The prototype shown above is for the glibc wrapper function; the raw system "
1610 "call interface has no I<fn> or I<arg> argument, and changes the order of the "
1611 "arguments so that I<flags> is the first argument, and I<tls> is the last "
1616 #: build/C/man2/clone.2:870
1618 "B<__clone2>() operates in the same way as B<clone>(), except that "
1619 "I<child_stack_base> points to the lowest address of the child's stack area, "
1620 "and I<stack_size> specifies the size of the stack pointed to by "
1621 "I<child_stack_base>."
1625 #: build/C/man2/clone.2:870
1627 msgid "Linux 2.4 and earlier"
1631 #: build/C/man2/clone.2:878
1633 "In Linux 2.4 and earlier, B<clone>() does not take arguments I<ptid>, "
1634 "I<tls>, and I<ctid>."
1637 #. gettid(2) returns current->pid;
1638 #. getpid(2) returns current->tgid;
1640 #: build/C/man2/clone.2:887
1642 "On success, the thread ID of the child process is returned in the caller's "
1643 "thread of execution. On failure, -1 is returned in the caller's context, no "
1644 "child process will be created, and I<errno> will be set appropriately."
1648 #: build/C/man2/clone.2:887 build/C/man2/kcmp.2:170 build/C/man2/sched_get_priority_max.2:107 build/C/man3/sched_getcpu.3:65 build/C/man2/sched_rr_get_interval.2:80 build/C/man2/sched_setaffinity.2:116 build/C/man2/sched_setattr.2:271 build/C/man2/sched_setparam.2:96 build/C/man2/sched_setscheduler.2:145 build/C/man2/sched_yield.2:48 build/C/man2/setns.2:77 build/C/man2/unshare.2:212
1654 #: build/C/man2/clone.2:888
1660 #: build/C/man2/clone.2:891
1661 msgid "Too many processes are already running."
1665 #: build/C/man2/clone.2:891 build/C/man2/clone.2:898 build/C/man2/clone.2:913 build/C/man2/clone.2:921 build/C/man2/clone.2:929 build/C/man2/clone.2:937 build/C/man2/clone.2:943 build/C/man2/clone.2:953 build/C/man2/clone.2:961 build/C/man2/clone.2:969 build/C/man2/kcmp.2:181 build/C/man2/sched_get_priority_max.2:108 build/C/man2/sched_rr_get_interval.2:84 build/C/man2/sched_setaffinity.2:120 build/C/man2/sched_setaffinity.2:128 build/C/man2/sched_setattr.2:276 build/C/man2/sched_setattr.2:300 build/C/man2/sched_setattr.2:323 build/C/man2/sched_setparam.2:97 build/C/man2/sched_setparam.2:104 build/C/man2/sched_setscheduler.2:146 build/C/man2/sched_setscheduler.2:153 build/C/man2/sched_setscheduler.2:158 build/C/man2/setns.2:82 build/C/man2/unshare.2:213
1671 #: build/C/man2/clone.2:898
1673 "B<CLONE_SIGHAND> was specified, but B<CLONE_VM> was not. (Since Linux "
1680 #. .B CLONE_DETACHED
1684 #. (Since Linux 2.6.0-test6.)
1686 #: build/C/man2/clone.2:913
1688 "B<CLONE_THREAD> was specified, but B<CLONE_SIGHAND> was not. (Since Linux "
1693 #: build/C/man2/clone.2:921
1694 msgid "Both B<CLONE_FS> and B<CLONE_NEWNS> were specified in I<flags>."
1698 #: build/C/man2/clone.2:929
1699 msgid "Both B<CLONE_NEWIPC> and B<CLONE_SYSVSEM> were specified in I<flags>."
1703 #: build/C/man2/clone.2:937
1704 msgid "Both B<CLONE_NEWPID> and B<CLONE_THREAD> were specified in I<flags>."
1708 #: build/C/man2/clone.2:943
1709 msgid "Returned by B<clone>() when a zero value is specified for I<child_stack>."
1713 #: build/C/man2/clone.2:953
1715 "B<CLONE_NEWIPC> was specified in I<flags>, but the kernel was not configured "
1716 "with the B<CONFIG_SYSVIPC> and B<CONFIG_IPC_NS> options."
1720 #: build/C/man2/clone.2:961
1722 "B<CLONE_NEWNET> was specified in I<flags>, but the kernel was not configured "
1723 "with the B<CONFIG_NET_NS> option."
1727 #: build/C/man2/clone.2:969
1729 "B<CLONE_NEWPID> was specified in I<flags>, but the kernel was not configured "
1730 "with the B<CONFIG_PID_NS> option."
1734 #: build/C/man2/clone.2:977
1736 "B<CLONE_NEWUTS> was specified in I<flags>, but the kernel was not configured "
1737 "with the B<CONFIG_UTS> option."
1741 #: build/C/man2/clone.2:977 build/C/man2/setns.2:89 build/C/man2/unshare.2:217
1747 #: build/C/man2/clone.2:982
1749 "Cannot allocate sufficient memory to allocate a task structure for the "
1750 "child, or to copy those parts of the caller's context that need to be "
1755 #: build/C/man2/clone.2:982 build/C/man2/clone.2:991 build/C/man2/kcmp.2:185 build/C/man2/sched_setaffinity.2:135 build/C/man2/sched_setattr.2:339 build/C/man2/sched_setattr.2:342 build/C/man2/sched_setparam.2:109 build/C/man2/sched_setscheduler.2:164 build/C/man2/setns.2:92 build/C/man2/unshare.2:221
1761 #: build/C/man2/clone.2:991
1763 "B<CLONE_NEWIPC>, B<CLONE_NEWNET>, B<CLONE_NEWNS>, B<CLONE_NEWPID>, or "
1764 "B<CLONE_NEWUTS> was specified by an unprivileged process (process without "
1765 "B<CAP_SYS_ADMIN>)."
1769 #: build/C/man2/clone.2:995
1770 msgid "B<CLONE_PID> was specified by a process other than process 0."
1774 #: build/C/man2/clone.2:1002
1776 "There is no entry for B<clone>() in libc5. glibc2 provides B<clone>() as "
1777 "described in this manual page."
1781 #: build/C/man2/clone.2:1006
1783 "B<clone>() is Linux-specific and should not be used in programs intended to "
1788 #: build/C/man2/clone.2:1016
1790 "In the kernel 2.4.x series, B<CLONE_THREAD> generally does not make the "
1791 "parent of the new thread the same as the parent of the calling process. "
1792 "However, for kernel versions 2.4.7 to 2.4.18 the B<CLONE_THREAD> flag "
1793 "implied the B<CLONE_PARENT> flag (as in kernel 2.6)."
1797 #: build/C/man2/clone.2:1026
1799 "For a while there was B<CLONE_DETACHED> (introduced in 2.5.32): parent wants "
1800 "no child-exit signal. In 2.6.2 the need to give this together with "
1801 "B<CLONE_THREAD> disappeared. This flag is still defined, but has no effect."
1805 #: build/C/man2/clone.2:1031
1807 "On i386, B<clone>() should not be called through vsyscall, but directly "
1808 "through I<int $0x80>."
1812 #: build/C/man2/clone.2:1062
1814 "Versions of the GNU C library that include the NPTL threading library "
1815 "contain a wrapper function for B<getpid>(2) that performs caching of PIDs. "
1816 "This caching relies on support in the glibc wrapper for B<clone>(), but as "
1817 "currently implemented, the cache may not be up to date in some "
1818 "circumstances. In particular, if a signal is delivered to the child "
1819 "immediately after the B<clone>() call, then a call to B<getpid>(2) in a "
1820 "handler for the signal may return the PID of the calling process (\"the "
1821 "parent\"), if the clone wrapper has not yet had a chance to update the PID "
1822 "cache in the child. (This discussion ignores the case where the child was "
1823 "created using B<CLONE_THREAD>, when B<getpid>(2) I<should> return the same "
1824 "value in the child and in the process that called B<clone>(), since the "
1825 "caller and the child are in the same thread group. The stale-cache problem "
1826 "also does not occur if the I<flags> argument includes B<CLONE_VM>.) To get "
1827 "the truth, it may be necessary to use code such as the following:"
1831 #: build/C/man2/clone.2:1065
1833 msgid " #include E<lt>syscall.hE<gt>\n"
1837 #: build/C/man2/clone.2:1067
1839 msgid " pid_t mypid;\n"
1843 #: build/C/man2/clone.2:1069
1845 msgid " mypid = syscall(SYS_getpid);\n"
1849 #: build/C/man2/clone.2:1083
1851 "The following program demonstrates the use of B<clone>() to create a child "
1852 "process that executes in a separate UTS namespace. The child changes the "
1853 "hostname in its UTS namespace. Both parent and child then display the "
1854 "system hostname, making it possible to see that the hostname differs in the "
1855 "UTS namespaces of the parent and child. For an example of the use of this "
1856 "program, see B<setns>(2)."
1860 #: build/C/man2/clone.2:1083 build/C/man2/setns.2:166
1862 msgid "Program source"
1866 #: build/C/man2/clone.2:1093
1869 "#define _GNU_SOURCE\n"
1870 "#include E<lt>sys/wait.hE<gt>\n"
1871 "#include E<lt>sys/utsname.hE<gt>\n"
1872 "#include E<lt>sched.hE<gt>\n"
1873 "#include E<lt>string.hE<gt>\n"
1874 "#include E<lt>stdio.hE<gt>\n"
1875 "#include E<lt>stdlib.hE<gt>\n"
1876 "#include E<lt>unistd.hE<gt>\n"
1880 #: build/C/man2/clone.2:1096 build/C/man2/setns.2:177
1883 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\e\n"
1888 #: build/C/man2/clone.2:1101
1891 "static int /* Start function for cloned child */\n"
1892 "childFunc(void *arg)\n"
1894 " struct utsname uts;\n"
1898 #: build/C/man2/clone.2:1103
1900 msgid " /* Change hostname in UTS namespace of child */\n"
1904 #: build/C/man2/clone.2:1106
1907 " if (sethostname(arg, strlen(arg)) == -1)\n"
1908 " errExit(\"sethostname\");\n"
1912 #: build/C/man2/clone.2:1108
1914 msgid " /* Retrieve and display hostname */\n"
1918 #: build/C/man2/clone.2:1112
1921 " if (uname(&uts) == -1)\n"
1922 " errExit(\"uname\");\n"
1923 " printf(\"uts.nodename in child: %s\\en\", uts.nodename);\n"
1927 #: build/C/man2/clone.2:1116
1930 " /* Keep the namespace open for a while, by sleeping.\n"
1931 " This allows some experimentation--for example, another\n"
1932 " process might join the namespace. */\n"
1936 #: build/C/man2/clone.2:1118
1938 msgid " sleep(200);\n"
1942 #: build/C/man2/clone.2:1121
1945 " return 0; /* Child terminates now */\n"
1950 #: build/C/man2/clone.2:1123
1952 msgid "#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */\n"
1956 #: build/C/man2/clone.2:1131
1960 "main(int argc, char *argv[])\n"
1962 " char *stack; /* Start of stack buffer */\n"
1963 " char *stackTop; /* End of stack buffer */\n"
1965 " struct utsname uts;\n"
1969 #: build/C/man2/clone.2:1136
1972 " if (argc E<lt> 2) {\n"
1973 " fprintf(stderr, \"Usage: %s E<lt>child-hostnameE<gt>\\en\", "
1975 " exit(EXIT_SUCCESS);\n"
1980 #: build/C/man2/clone.2:1138
1982 msgid " /* Allocate stack for child */\n"
1986 #: build/C/man2/clone.2:1143
1989 " stack = malloc(STACK_SIZE);\n"
1990 " if (stack == NULL)\n"
1991 " errExit(\"malloc\");\n"
1992 " stackTop = stack + STACK_SIZE; /* Assume stack grows downward */\n"
1996 #: build/C/man2/clone.2:1146
1999 " /* Create child that has its own UTS namespace;\n"
2000 " child commences execution in childFunc() */\n"
2004 #: build/C/man2/clone.2:1151
2007 " pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);\n"
2009 " errExit(\"clone\");\n"
2010 " printf(\"clone() returned %ld\\en\", (long) pid);\n"
2014 #: build/C/man2/clone.2:1153
2016 msgid " /* Parent falls through to here */\n"
2020 #: build/C/man2/clone.2:1155
2022 msgid " sleep(1); /* Give child time to change its hostname */\n"
2026 #: build/C/man2/clone.2:1158
2029 " /* Display hostname in parent\\(aqs UTS namespace. This will be\n"
2030 " different from hostname in child\\(aqs UTS namespace. */\n"
2034 #: build/C/man2/clone.2:1162
2037 " if (uname(&uts) == -1)\n"
2038 " errExit(\"uname\");\n"
2039 " printf(\"uts.nodename in parent: %s\\en\", uts.nodename);\n"
2043 #: build/C/man2/clone.2:1166
2046 " if (waitpid(pid, NULL, 0) == -1) /* Wait for child */\n"
2047 " errExit(\"waitpid\");\n"
2048 " printf(\"child has terminated\\en\");\n"
2052 #: build/C/man2/clone.2:1169
2055 " exit(EXIT_SUCCESS);\n"
2060 #: build/C/man2/clone.2:1184
2062 "B<fork>(2), B<futex>(2), B<getpid>(2), B<gettid>(2), B<kcmp>(2), "
2063 "B<set_thread_area>(2), B<set_tid_address>(2), B<setns>(2), B<tkill>(2), "
2064 "B<unshare>(2), B<wait>(2), B<capabilities>(7), B<pthreads>(7)"
2068 #: build/C/man2/kcmp.2:28
2074 #: build/C/man2/kcmp.2:28
2080 #: build/C/man2/kcmp.2:31
2081 msgid "kcmp - compare two processes to determine if they share a kernel resource"
2085 #: build/C/man2/kcmp.2:34
2087 msgid "B<#include E<lt>linux/kcmp.hE<gt>>\n"
2091 #: build/C/man2/kcmp.2:37
2094 "B<int kcmp(pid_t >I<pid1>B<, pid_t >I<pid2>B<, int >I<type>B<,>\n"
2095 "B< unsigned long >I<idx1>B<, unsigned long >I<idx2>B<);>\n"
2099 #: build/C/man2/kcmp.2:41
2100 msgid "I<Note>: There is no glibc wrapper for this system call; see NOTES."
2104 #: build/C/man2/kcmp.2:50
2106 "The B<kcmp>() system call can be used to check whether the two processes "
2107 "identified by I<pid1> and I<pid2> share a kernel resource such as virtual "
2108 "memory, file descriptors, and so on."
2112 #: build/C/man2/kcmp.2:55
2114 "The I<type> argument specifies which resource is to be compared in the two "
2115 "processes. It has one of the following values:"
2119 #: build/C/man2/kcmp.2:55
2121 msgid "B<KCMP_FILE>"
2125 #: build/C/man2/kcmp.2:67
2127 "Check whether a file descriptor I<idx1> in the process I<pid1> refers to the "
2128 "same open file description (see B<open>(2)) as file descriptor I<idx2> in "
2129 "the process I<pid2>."
2133 #: build/C/man2/kcmp.2:67
2135 msgid "B<KCMP_FILES>"
2139 #: build/C/man2/kcmp.2:75
2141 "Check whether the process share the same set of open file descriptors. The "
2142 "arguments I<idx1> and I<idx2> are ignored."
2146 #: build/C/man2/kcmp.2:75
2152 #: build/C/man2/kcmp.2:84
2154 "Check whether the processes share the same filesystem information (i.e., "
2155 "file mode creation mask, working directory, and filesystem root). The "
2156 "arguments I<idx1> and I<idx2> are ignored."
2160 #: build/C/man2/kcmp.2:84
2166 #: build/C/man2/kcmp.2:92
2168 "Check whether the processes share I/O context. The arguments I<idx1> and "
2169 "I<idx2> are ignored."
2173 #: build/C/man2/kcmp.2:92
2175 msgid "B<KCMP_SIGHAND>"
2179 #: build/C/man2/kcmp.2:100
2181 "Check whether the processes share the same table of signal dispositions. "
2182 "The arguments I<idx1> and I<idx2> are ignored."
2186 #: build/C/man2/kcmp.2:100
2188 msgid "B<KCMP_SYSVSEM>"
2192 #: build/C/man2/kcmp.2:109
2194 "Check whether the processes share the same list of System\\ V semaphore undo "
2195 "operations. The arguments I<idx1> and I<idx2> are ignored."
2199 #: build/C/man2/kcmp.2:109
2205 #: build/C/man2/kcmp.2:117
2207 "Check whether the processes share the same address space. The arguments "
2208 "I<idx1> and I<idx2> are ignored."
2212 #: build/C/man2/kcmp.2:127
2214 "Note the B<kcmp>() is not protected against false positives which may occur "
2215 "if tasks are running. One should stop tasks by sending B<SIGSTOP> (see "
2216 "B<signal>(7)) prior to inspection with this system call to obtain "
2217 "meaningful results."
2221 #: build/C/man2/kcmp.2:133
2223 "The return value of a successful call to B<kcmp>() is simply the result of "
2224 "arithmetic comparison of kernel pointers (when the kernel compares "
2225 "resources, it uses their memory addresses)."
2229 #: build/C/man2/kcmp.2:141
2231 "The easiest way to explain is to consider an example. Suppose that I<v1> "
2232 "and I<v2> are the addresses of appropriate resources, then the return value "
2233 "is one of the following:"
2237 #: build/C/man2/kcmp.2:142
2243 #: build/C/man2/kcmp.2:147
2245 "I<v1> is equal to I<v2>; in other words, the two processes share the "
2250 #: build/C/man2/kcmp.2:147
2256 #: build/C/man2/kcmp.2:151
2257 msgid "I<v1> is less than I<v2>."
2261 #: build/C/man2/kcmp.2:151
2267 #: build/C/man2/kcmp.2:155
2268 msgid "I<v1> is greater than I<v2>."
2272 #: build/C/man2/kcmp.2:155
2278 #: build/C/man2/kcmp.2:160
2279 msgid "I<v1> is not equal to I<v2>, but ordering information is unavailable."
2283 #: build/C/man2/kcmp.2:165
2284 msgid "On error, -1 is returned, and I<errno> is set appropriately."
2288 #: build/C/man2/kcmp.2:170
2290 "B<kcmp>() was designed to return values suitable for sorting. This is "
2291 "particularly handy if one needs to compare a large number of file "
2296 #: build/C/man2/kcmp.2:171 build/C/man2/setns.2:78
2302 #: build/C/man2/kcmp.2:181
2303 msgid "I<type> is B<KCMP_FILE> and I<fd1> or I<fd2> is not an open file descriptor."
2307 #: build/C/man2/kcmp.2:185
2308 msgid "I<type> is invalid."
2312 #: build/C/man2/kcmp.2:191
2314 "Insufficient permission to inspect process resources. The B<CAP_SYS_PTRACE> "
2315 "capability is required to inspect processes that you do not own."
2319 #: build/C/man2/kcmp.2:191 build/C/man2/sched_rr_get_interval.2:90 build/C/man2/sched_setaffinity.2:145 build/C/man2/sched_setattr.2:284 build/C/man2/sched_setparam.2:116 build/C/man2/sched_setscheduler.2:167
2325 #: build/C/man2/kcmp.2:198
2326 msgid "Process I<pid1> or I<pid2> does not exist."
2330 #: build/C/man2/kcmp.2:202
2331 msgid "The B<kcmp>() system call first appeared in Linux 3.5."
2335 #: build/C/man2/kcmp.2:205
2337 "B<kcmp>() is Linux-specific and should not be used in programs intended to "
2342 #: build/C/man2/kcmp.2:208
2344 "Glibc does not provide a wrapper for this system call; call it using "
2349 #: build/C/man2/kcmp.2:217
2351 "This system call is available only if the kernel was configured with "
2352 "B<CONFIG_CHECKPOINT_RESTORE>. The main use of the system call is for the "
2353 "checkpoint/restore in user space (CRIU) feature. The alternative to this "
2354 "system call would have been to expose suitable process information via the "
2355 "B<proc>(5) filesystem; this was deemed to be unsuitable for security "
2360 #: build/C/man2/kcmp.2:222
2362 "See B<clone>(2) for some background information on the shared resources "
2363 "referred to on this page."
2367 #: build/C/man2/kcmp.2:225
2368 msgid "B<clone>(2), B<unshare>(2)"
2372 #: build/C/man2/sched_get_priority_max.2:29
2374 msgid "SCHED_GET_PRIORITY_MAX"
2378 #: build/C/man2/sched_get_priority_max.2:29
2384 #: build/C/man2/sched_get_priority_max.2:32
2385 msgid "sched_get_priority_max, sched_get_priority_min - get static priority range"
2389 #: build/C/man2/sched_get_priority_max.2:34 build/C/man2/sched_rr_get_interval.2:34 build/C/man2/sched_yield.2:34
2390 msgid "B<#include E<lt>sched.hE<gt>>"
2394 #: build/C/man2/sched_get_priority_max.2:36
2395 msgid "B<int sched_get_priority_max(int >I<policy>B<);>"
2399 #: build/C/man2/sched_get_priority_max.2:38
2400 msgid "B<int sched_get_priority_min(int >I<policy>B<);>"
2404 #: build/C/man2/sched_get_priority_max.2:59
2406 "B<sched_get_priority_max>() returns the maximum priority value that can be "
2407 "used with the scheduling algorithm identified by I<policy>. "
2408 "B<sched_get_priority_min>() returns the minimum priority value that can be "
2409 "used with the scheduling algorithm identified by I<policy>. Supported "
2410 "I<policy> values are B<SCHED_FIFO>, B<SCHED_RR>, B<SCHED_OTHER>, "
2411 "B<SCHED_BATCH>, B<SCHED_IDLE>, and B<SCHED_DEADLINE>. Further details about "
2412 "these policies can be found in B<sched>(7)."
2416 #: build/C/man2/sched_get_priority_max.2:68
2418 "Processes with numerically higher priority values are scheduled before "
2419 "processes with numerically lower priority values. Thus, the value returned "
2420 "by B<sched_get_priority_max>() will be greater than the value returned by "
2421 "B<sched_get_priority_min>()."
2425 #: build/C/man2/sched_get_priority_max.2:76
2427 "Linux allows the static priority range 1 to 99 for the B<SCHED_FIFO> and "
2428 "B<SCHED_RR> policies, and the priority 0 for the remaining policies. "
2429 "Scheduling priority ranges for the various policies are not alterable."
2433 #: build/C/man2/sched_get_priority_max.2:88
2435 "The range of scheduling priorities may vary on other POSIX systems, thus it "
2436 "is a good idea for portable applications to use a virtual priority range and "
2437 "map it to the interval given by B<sched_get_priority_max>() and "
2438 "B<sched_get_priority_min>(). POSIX.1-2001 requires a spread of at least 32 "
2439 "between the maximum and the minimum values for B<SCHED_FIFO> and "
2444 #: build/C/man2/sched_get_priority_max.2:97
2446 "POSIX systems on which B<sched_get_priority_max>() and "
2447 "B<sched_get_priority_min>() are available define "
2448 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2452 #: build/C/man2/sched_get_priority_max.2:107
2454 "On success, B<sched_get_priority_max>() and B<sched_get_priority_min>() "
2455 "return the maximum/minimum priority value for the named scheduling policy. "
2456 "On error, -1 is returned, and I<errno> is set appropriately."
2460 #: build/C/man2/sched_get_priority_max.2:113
2461 msgid "The argument I<policy> does not identify a defined scheduling policy."
2465 #: build/C/man2/sched_get_priority_max.2:115 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setparam.2:121 build/C/man2/sched_yield.2:54
2466 msgid "POSIX.1-2001."
2470 #: build/C/man2/sched_get_priority_max.2:125
2472 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_getscheduler>(2), "
2473 "B<sched_setaffinity>(2), B<sched_setparam>(2), B<sched_setscheduler>(2), "
2478 #: build/C/man3/sched_getcpu.3:26
2480 msgid "SCHED_GETCPU"
2484 #: build/C/man3/sched_getcpu.3:26 build/C/man2/sched_setaffinity.2:34
2490 #: build/C/man3/sched_getcpu.3:29
2491 msgid "sched_getcpu - determine CPU on which the calling thread is running"
2495 #: build/C/man3/sched_getcpu.3:34
2497 msgid "B<int sched_getcpu(void);>\n"
2501 #: build/C/man3/sched_getcpu.3:39 build/C/man2/unshare.2:33
2502 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
2506 #: build/C/man3/sched_getcpu.3:42
2507 msgid "B<sched_getcpu>():"
2511 #: build/C/man3/sched_getcpu.3:58
2513 "B<sched_getcpu>() returns the number of the CPU on which the calling thread "
2514 "is currently executing."
2518 #: build/C/man3/sched_getcpu.3:65
2520 "On success, B<sched_getcpu>() returns a nonnegative CPU number. On error, "
2521 "-1 is returned and I<errno> is set to indicate the error."
2525 #: build/C/man3/sched_getcpu.3:66 build/C/man2/sched_rr_get_interval.2:87
2531 #: build/C/man3/sched_getcpu.3:70
2532 msgid "This kernel does not implement B<getcpu>(2)."
2536 #: build/C/man3/sched_getcpu.3:72
2537 msgid "This function is available since glibc 2.6."
2541 #: build/C/man3/sched_getcpu.3:72
2547 #: build/C/man3/sched_getcpu.3:73
2549 msgid "Multithreading (see pthreads(7))"
2553 #: build/C/man3/sched_getcpu.3:77
2554 msgid "The B<sched_getcpu>() function is thread-safe."
2558 #: build/C/man3/sched_getcpu.3:80
2559 msgid "B<sched_getcpu>() is glibc-specific."
2563 #: build/C/man3/sched_getcpu.3:82
2568 #: build/C/man3/sched_getcpu.3:86
2570 msgid "cpu = sched_getcpu();\n"
2574 #: build/C/man3/sched_getcpu.3:92
2575 msgid "is equivalent to the following B<getcpu>(2) call:"
2579 #: build/C/man3/sched_getcpu.3:98
2583 "s = getcpu(&c, NULL, NULL);\n"
2584 "cpu = (s == -1) ? s : c;\n"
2588 #: build/C/man3/sched_getcpu.3:103
2589 msgid "B<getcpu>(2), B<sched>(7)"
2593 #: build/C/man2/sched_rr_get_interval.2:29
2595 msgid "SCHED_RR_GET_INTERVAL"
2599 #: build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_yield.2:29
2605 #: build/C/man2/sched_rr_get_interval.2:32
2606 msgid "sched_rr_get_interval - get the SCHED_RR interval for the named process"
2610 #: build/C/man2/sched_rr_get_interval.2:36
2611 msgid "B<int sched_rr_get_interval(pid_t >I<pid>B<, struct timespec * >I<tp>B<);>"
2615 #: build/C/man2/sched_rr_get_interval.2:47
2617 "B<sched_rr_get_interval>() writes into the I<timespec> structure pointed to "
2618 "by I<tp> the round-robin time quantum for the process identified by I<pid>. "
2619 "The specified process should be running under the B<SCHED_RR> scheduling "
2624 #: build/C/man2/sched_rr_get_interval.2:51
2625 msgid "The I<timespec> structure has the following form:"
2629 #: build/C/man2/sched_rr_get_interval.2:58
2632 "struct timespec {\n"
2633 " time_t tv_sec; /* seconds */\n"
2634 " long tv_nsec; /* nanoseconds */\n"
2638 #. FIXME . On Linux, sched_rr_get_interval()
2639 #. returns the timeslice for SCHED_OTHER processes -- this timeslice
2640 #. is influenced by the nice value.
2641 #. For SCHED_FIFO processes, this always returns 0.
2643 #. The round-robin time quantum value is not alterable under Linux
2646 #: build/C/man2/sched_rr_get_interval.2:73
2648 "If I<pid> is zero, the time quantum for the calling process is written into "
2653 #: build/C/man2/sched_rr_get_interval.2:80
2655 "On success, B<sched_rr_get_interval>() returns 0. On error, -1 is "
2656 "returned, and I<errno> is set appropriately."
2660 #: build/C/man2/sched_rr_get_interval.2:81 build/C/man2/sched_setaffinity.2:117
2666 #: build/C/man2/sched_rr_get_interval.2:84
2667 msgid "Problem with copying information to user space."
2671 #: build/C/man2/sched_rr_get_interval.2:87
2672 msgid "Invalid pid."
2676 #: build/C/man2/sched_rr_get_interval.2:90
2677 msgid "The system call is not yet implemented (only on rather old kernels)."
2681 #: build/C/man2/sched_rr_get_interval.2:94
2682 msgid "Could not find a process with the ID I<pid>."
2686 #: build/C/man2/sched_rr_get_interval.2:103
2688 "POSIX systems on which B<sched_rr_get_interval>() is available define "
2689 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2693 #: build/C/man2/sched_rr_get_interval.2:103
2698 #. commit a4ec24b48ddef1e93f7578be53270f0b95ad666c
2700 #: build/C/man2/sched_rr_get_interval.2:117
2702 "POSIX does not specify any mechanism for controlling the size of the "
2703 "round-robin time quantum. Older Linux kernels provide a (nonportable) "
2704 "method of doing this. The quantum can be controlled by adjusting the "
2705 "process's nice value (see B<setpriority>(2)). Assigning a negative (i.e., "
2706 "high) nice value results in a longer quantum; assigning a positive (i.e., "
2707 "low) nice value results in a shorter quantum. The default quantum is 0.1 "
2708 "seconds; the degree to which changing the nice value affects the quantum has "
2709 "varied somewhat across kernel versions. This method of adjusting the "
2710 "quantum was removed starting with Linux 2.6.24."
2713 #. commit ce0dbbbb30aee6a835511d5be446462388ba9eee
2715 #. As of Linux 1.3.81
2716 #. .BR sched_rr_get_interval ()
2717 #. returns with error
2718 #. ENOSYS, because SCHED_RR has not yet been fully implemented and tested
2721 #: build/C/man2/sched_rr_get_interval.2:132
2723 "Linux 3.9 added a new mechanism for adjusting (and viewing) the B<SCHED_RR> "
2724 "quantum: the I</proc/sys/kernel/sched_rr_timeslice_ms> file exposes the "
2725 "quantum as a millisecond value, whose default is 100. Writing 0 to this "
2726 "file resets the quantum to the default value."
2730 #: build/C/man2/sched_rr_get_interval.2:134 build/C/man2/sched_yield.2:81
2735 #: build/C/man2/sched_setaffinity.2:34
2737 msgid "SCHED_SETAFFINITY"
2741 #: build/C/man2/sched_setaffinity.2:38
2743 "sched_setaffinity, sched_getaffinity - set and get a thread's CPU affinity "
2748 #: build/C/man2/sched_setaffinity.2:45
2751 "B<int sched_setaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2752 "B< const cpu_set_t *>I<mask>B<);>\n"
2756 #: build/C/man2/sched_setaffinity.2:48
2759 "B<int sched_getaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2760 "B< cpu_set_t *>I<mask>B<);>\n"
2764 #: build/C/man2/sched_setaffinity.2:63
2766 "A thread's CPU affinity mask determines the set of CPUs on which it is "
2767 "eligible to run. On a multiprocessor system, setting the CPU affinity mask "
2768 "can be used to obtain performance benefits. For example, by dedicating one "
2769 "CPU to a particular thread (i.e., setting the affinity mask of that thread "
2770 "to specify a single CPU, and setting the affinity mask of all other threads "
2771 "to exclude that CPU), it is possible to ensure maximum execution speed for "
2772 "that thread. Restricting a thread to run on a single CPU also avoids the "
2773 "performance cost caused by the cache invalidation that occurs when a thread "
2774 "ceases to execute on one CPU and then recommences execution on a different "
2779 #: build/C/man2/sched_setaffinity.2:70
2781 "A CPU affinity mask is represented by the I<cpu_set_t> structure, a \"CPU "
2782 "set\", pointed to by I<mask>. A set of macros for manipulating CPU sets is "
2783 "described in B<CPU_SET>(3)."
2787 #: build/C/man2/sched_setaffinity.2:85
2789 "B<sched_setaffinity>() sets the CPU affinity mask of the thread whose ID is "
2790 "I<pid> to the value specified by I<mask>. If I<pid> is zero, then the "
2791 "calling thread is used. The argument I<cpusetsize> is the length (in bytes) "
2792 "of the data pointed to by I<mask>. Normally this argument would be "
2793 "specified as I<sizeof(cpu_set_t)>."
2797 #: build/C/man2/sched_setaffinity.2:92
2799 "If the thread specified by I<pid> is not currently running on one of the "
2800 "CPUs specified in I<mask>, then that thread is migrated to one of the CPUs "
2801 "specified in I<mask>."
2805 #: build/C/man2/sched_setaffinity.2:107
2807 "B<sched_getaffinity>() writes the affinity mask of the thread whose ID is "
2808 "I<pid> into the I<cpu_set_t> structure pointed to by I<mask>. The "
2809 "I<cpusetsize> argument specifies the size (in bytes) of I<mask>. If I<pid> "
2810 "is zero, then the mask of the calling thread is returned."
2814 #: build/C/man2/sched_setaffinity.2:116
2816 "On success, B<sched_setaffinity>() and B<sched_getaffinity>() return 0. "
2817 "On error, -1 is returned, and I<errno> is set appropriately."
2821 #: build/C/man2/sched_setaffinity.2:120
2822 msgid "A supplied memory address was invalid."
2826 #: build/C/man2/sched_setaffinity.2:128
2828 "The affinity bit mask I<mask> contains no processors that are currently "
2829 "physically on the system and permitted to the thread according to any "
2830 "restrictions that may be imposed by the \"cpuset\" mechanism described in "
2835 #: build/C/man2/sched_setaffinity.2:135
2837 "(B<sched_getaffinity>() and, in kernels before 2.6.9, "
2838 "B<sched_setaffinity>()) I<cpusetsize> is smaller than the size of the "
2839 "affinity mask used by the kernel."
2843 #: build/C/man2/sched_setaffinity.2:145
2845 "(B<sched_setaffinity>()) The calling thread does not have appropriate "
2846 "privileges. The caller needs an effective user ID equal to the real user ID "
2847 "or effective user ID of the thread identified by I<pid>, or it must possess "
2848 "the B<CAP_SYS_NICE> capability."
2852 #: build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setattr.2:289 build/C/man2/sched_setscheduler.2:170
2853 msgid "The thread whose ID is I<pid> could not be found."
2857 #: build/C/man2/sched_setaffinity.2:159
2859 "The CPU affinity system calls were introduced in Linux kernel 2.5.8. The "
2860 "system call wrappers were introduced in glibc 2.3. Initially, the glibc "
2861 "interfaces included a I<cpusetsize> argument, typed as I<unsigned int>. In "
2862 "glibc 2.3.3, the I<cpusetsize> argument was removed, but was then restored "
2863 "in glibc 2.3.4, with type I<size_t>."
2867 #: build/C/man2/sched_setaffinity.2:161
2868 msgid "These system calls are Linux-specific."
2872 #: build/C/man2/sched_setaffinity.2:174
2874 "After a call to B<sched_setaffinity>(), the set of CPUs on which the thread "
2875 "will actually run is the intersection of the set specified in the I<mask> "
2876 "argument and the set of CPUs actually present on the system. The system may "
2877 "further restrict the set of CPUs on which the thread runs if the \"cpuset\" "
2878 "mechanism described in B<cpuset>(7) is being used. These restrictions on "
2879 "the actual set of CPUs on which the thread will run are silently imposed by "
2884 #: build/C/man2/sched_setaffinity.2:177
2885 msgid "B<sched>(7) has a description of the Linux scheduling scheme."
2889 #: build/C/man2/sched_setaffinity.2:194
2891 "The affinity mask is a per-thread attribute that can be adjusted "
2892 "independently for each of the threads in a thread group. The value returned "
2893 "from a call to B<gettid>(2) can be passed in the argument I<pid>. "
2894 "Specifying I<pid> as 0 will set the attribute for the calling thread, and "
2895 "passing the value returned from a call to B<getpid>(2) will set the "
2896 "attribute for the main thread of the thread group. (If you are using the "
2897 "POSIX threads API, then use B<pthread_setaffinity_np>(3) instead of "
2898 "B<sched_setaffinity>().)"
2902 #: build/C/man2/sched_setaffinity.2:200
2904 "A child created via B<fork>(2) inherits its parent's CPU affinity mask. "
2905 "The affinity mask is preserved across an B<execve>(2)."
2909 #: build/C/man2/sched_setaffinity.2:214
2911 "This manual page describes the glibc interface for the CPU affinity calls. "
2912 "The actual system call interface is slightly different, with the I<mask> "
2913 "being typed as I<unsigned long\\ *>, reflecting the fact that the underlying "
2914 "implementation of CPU sets is a simple bit mask. On success, the raw "
2915 "B<sched_getaffinity>() system call returns the size (in bytes) of the "
2916 "I<cpumask_t> data type that is used internally by the kernel to represent "
2917 "the CPU set bit mask."
2921 #: build/C/man2/sched_setaffinity.2:234
2923 "B<taskset>(1), B<clone>(2), B<getcpu>(2), B<getpriority>(2), B<gettid>(2), "
2924 "B<nice>(2), B<sched_get_priority_max>(2), B<sched_get_priority_min>(2), "
2925 "B<sched_getscheduler>(2), B<sched_setscheduler>(2), B<setpriority>(2), "
2926 "B<CPU_SET>(3), B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), "
2927 "B<capabilities>(7), B<cpuset>(7), B<sched>(7)"
2931 #: build/C/man2/sched_setattr.2:26
2933 msgid "SCHED_SETATTR"
2937 #: build/C/man2/sched_setattr.2:26 build/C/man7/sched.7:32
2943 #: build/C/man2/sched_setattr.2:30
2944 msgid "sched_setattr, sched_getattr - set and get scheduling policy and attributes"
2948 #: build/C/man2/sched_setattr.2:36
2951 "B<int sched_setattr(pid_t >I<pid>B<, const struct sched_attr *>I<attr>B<,>\n"
2952 "B< unsigned int >I<flags>B<);>\n"
2956 #: build/C/man2/sched_setattr.2:39
2959 "B<int sched_getattr(pid_t >I<pid>B<, const struct sched_attr *>I<attr>B<,>\n"
2960 "B< unsigned int >I<size>B<, unsigned int >I<flags>B<);>\n"
2964 #: build/C/man2/sched_setattr.2:42
2966 msgid "sched_setattr()"
2970 #: build/C/man2/sched_setattr.2:52
2972 "The B<sched_setattr>() system call sets the scheduling policy and "
2973 "associated attributes for the thread whose ID is specified in I<pid>. If "
2974 "I<pid> equals zero, the scheduling policy and attributes of the calling "
2975 "thread will be set."
2979 #: build/C/man2/sched_setattr.2:56 build/C/man2/sched_setscheduler.2:73
2981 "Currently, Linux supports the following \"normal\" (i.e., non-real-time) "
2982 "scheduling policies as values that may be specified in I<policy>:"
2986 #: build/C/man2/sched_setattr.2:56 build/C/man2/sched_setscheduler.2:73
2988 msgid "B<SCHED_OTHER>"
2991 #. In the 2.6 kernel sources, SCHED_OTHER is actually called
2994 #: build/C/man2/sched_setattr.2:61 build/C/man2/sched_setscheduler.2:78
2995 msgid "the standard round-robin time-sharing policy;"
2999 #: build/C/man2/sched_setattr.2:61 build/C/man2/sched_setscheduler.2:78
3001 msgid "B<SCHED_BATCH>"
3005 #: build/C/man2/sched_setattr.2:64 build/C/man2/sched_setscheduler.2:81
3006 msgid "for \"batch\" style execution of processes; and"
3010 #: build/C/man2/sched_setattr.2:64 build/C/man2/sched_setscheduler.2:81
3012 msgid "B<SCHED_IDLE>"
3016 #: build/C/man2/sched_setattr.2:69 build/C/man2/sched_setscheduler.2:86
3017 msgid "for running I<very> low priority background jobs."
3021 #: build/C/man2/sched_setattr.2:78 build/C/man2/sched_setscheduler.2:99
3023 "Various \"real-time\" policies are also supported, for special time-critical "
3024 "applications that need precise control over the way in which runnable "
3025 "threads are selected for execution. For the rules governing when a process "
3026 "may use these policies, see B<sched>(7). The real-time policies that may be "
3027 "specified in I<policy> are:"
3031 #: build/C/man2/sched_setattr.2:78 build/C/man2/sched_setscheduler.2:99
3033 msgid "B<SCHED_FIFO>"
3037 #: build/C/man2/sched_setattr.2:81 build/C/man2/sched_setscheduler.2:102
3038 msgid "a first-in, first-out policy; and"
3042 #: build/C/man2/sched_setattr.2:81 build/C/man2/sched_setscheduler.2:102
3048 #: build/C/man2/sched_setattr.2:84 build/C/man2/sched_setscheduler.2:105
3049 msgid "a round-robin policy."
3053 #: build/C/man2/sched_setattr.2:86
3054 msgid "Linux also provides the following policy:"
3058 #: build/C/man2/sched_setattr.2:86
3060 msgid "B<SCHED_DEADLINE>"
3064 #: build/C/man2/sched_setattr.2:91
3065 msgid "a deadline scheduling policy; see B<sched>(7) for details."
3069 #: build/C/man2/sched_setattr.2:97
3071 "The I<attr> argument is a pointer to a structure that defines the new "
3072 "scheduling policy and attributes for the specified thread. This structure "
3073 "has the following form:"
3077 #: build/C/man2/sched_setattr.2:113
3080 "struct sched_attr {\n"
3081 " u32 size; /* Size of this structure */\n"
3082 " u32 sched_policy; /* Policy (SCHED_*) */\n"
3083 " u64 sched_flags; /* Flags */\n"
3084 " s32 sched_nice; /* Nice value (SCHED_OTHER,\n"
3085 " SCHED_BATCH) */\n"
3086 " u32 sched_priority; /* Static priority (SCHED_FIFO,\n"
3088 " /* Remaining fields are for SCHED_DEADLINE */\n"
3089 " u64 sched_runtime;\n"
3090 " u64 sched_deadline;\n"
3091 " u64 sched_period;\n"
3096 #: build/C/man2/sched_setattr.2:117
3097 msgid "The fields of this structure are as follows:"
3101 #: build/C/man2/sched_setattr.2:117
3107 #: build/C/man2/sched_setattr.2:132
3109 "This field should be set to the size of the structure in bytes, as in "
3110 "I<sizeof(struct sched_attr)>. If the provided structure is smaller than the "
3111 "kernel structure, any additional fields are assumed to be '0'. If the "
3112 "provided structure is larger than the kernel structure, the kernel verifies "
3113 "that all additional fields are 0; if they are not, B<sched_setattr>() fails "
3114 "with the error B<E2BIG> and updates I<size> to contain the size of the "
3119 #: build/C/man2/sched_setattr.2:146
3121 "The above behavior when the size of the user-space I<sched_attr> structure "
3122 "does not match the size of the kernel structure allows for future "
3123 "extensibility of the interface. Malformed applications that pass oversize "
3124 "structures won't break in the future if the size of the kernel I<sched_attr> "
3125 "structure is increased. In the future, it could also allow applications "
3126 "that know about a larger user-space I<sched_attr> structure to determine "
3127 "whether they are running on an older kernel that does not support the larger "
3132 #: build/C/man2/sched_setattr.2:146
3134 msgid "I<sched_policy>"
3138 #: build/C/man2/sched_setattr.2:151
3140 "This field specifies the scheduling policy, as one of the B<SCHED_*> values "
3145 #: build/C/man2/sched_setattr.2:151
3147 msgid "I<sched_flags>"
3151 #: build/C/man2/sched_setattr.2:162
3153 "This field contains flags controlling scheduling behavior. Only one such "
3154 "flag is currently defined: B<SCHED_FLAG_RESET_ON_FORK>. As a result of "
3155 "including this flag, children created by B<fork>(2) do not inherit "
3156 "privileged scheduling policies. See B<sched>(7) for details."
3160 #: build/C/man2/sched_setattr.2:162
3162 msgid "I<sched_nice>"
3166 #: build/C/man2/sched_setattr.2:173
3168 "This field specifies the nice value to be set when specifying "
3169 "I<sched_policy> as B<SCHED_OTHER> or B<SCHED_BATCH>. The nice value is a "
3170 "number in the range -20 (high priority) to +19 (low priority); see "
3171 "B<setpriority>(2)."
3175 #: build/C/man2/sched_setattr.2:173
3177 msgid "I<sched_priority>"
3181 #: build/C/man2/sched_setattr.2:186
3183 "This field specifies the static priority to be set when specifying "
3184 "I<sched_policy> as B<SCHED_FIFO> or B<SCHED_RR>. The allowed range of "
3185 "priorities for these policies can be determined using "
3186 "B<sched_get_priority_min>(2) and B<sched_get_priority_max>(2). For other "
3187 "policies, this field must be specified as 0."
3191 #: build/C/man2/sched_setattr.2:186
3193 msgid "I<sched_runtime>"
3197 #: build/C/man2/sched_setattr.2:195
3199 "This field specifies the \"Runtime\" parameter for deadline scheduling. The "
3200 "value is expressed in nanoseconds. This field, and the next two fields, are "
3201 "used only for B<SCHED_DEADLINE> scheduling; for further details, see "
3206 #: build/C/man2/sched_setattr.2:195
3208 msgid "I<sched_deadline>"
3212 #: build/C/man2/sched_setattr.2:199
3214 "This field specifies the \"Deadline\" parameter for deadline scheduling. "
3215 "The value is expressed in nanoseconds."
3219 #: build/C/man2/sched_setattr.2:199
3221 msgid "I<sched_period>"
3225 #: build/C/man2/sched_setattr.2:203
3227 "This field specifies the \"Period\" parameter for deadline scheduling. The "
3228 "value is expressed in nanoseconds."
3232 #: build/C/man2/sched_setattr.2:210 build/C/man2/sched_setattr.2:262
3234 "The I<flags> argument is provided to allow for future extensions to the "
3235 "interface; in the current implementation it must be specified as 0."
3239 #: build/C/man2/sched_setattr.2:210
3241 msgid "sched_getattr()"
3245 #: build/C/man2/sched_setattr.2:221
3247 "The B<sched_getattr>() system call fetches the scheduling policy and the "
3248 "associated attributes for the thread whose ID is specified in I<pid>. If "
3249 "I<pid> equals zero, the scheduling policy and attributes of the calling "
3250 "thread will be retrieved."
3254 #: build/C/man2/sched_setattr.2:231
3256 "The I<size> argument should be set to the size of the I<sched_attr> "
3257 "structure as known to user space. The value must be at least as large as "
3258 "the size of the initially published I<sched_attr> structure, or the call "
3259 "fails with the error B<EINVAL>."
3263 #: build/C/man2/sched_setattr.2:241
3265 "The retrieved scheduling attributes are placed in the fields of the "
3266 "I<sched_attr> structure pointed to by I<attr>. The kernel sets I<attr.size> "
3267 "to the size of its I<sched_attr> structure."
3271 #: build/C/man2/sched_setattr.2:257
3273 "If the caller-provided I<attr> buffer is larger than the kernel's "
3274 "I<sched_attr> structure, the additional bytes in the user-space structure "
3275 "are not touched. If the caller-provided structure is smaller than the "
3276 "kernel I<sched_attr> structure and the kernel needs to return values outside "
3277 "the provided space, B<sched_getattr>() fails with the error B<E2BIG>. As "
3278 "with B<sched_setattr>(), these semantics allow for future extensibility of "
3283 #: build/C/man2/sched_setattr.2:271
3285 "On success, B<sched_setattr>() and B<sched_getattr>() return 0. On error, "
3286 "-1 is returned, and I<errno> is set to indicate the cause of the error."
3290 #: build/C/man2/sched_setattr.2:276
3292 "B<sched_getattr>() and B<sched_setattr>() can both fail for the following "
3297 #: build/C/man2/sched_setattr.2:284
3298 msgid "I<attr> is NULL; or I<pid> is negative; or I<flags> is not zero."
3302 #: build/C/man2/sched_setattr.2:293
3303 msgid "In addition, B<sched_getattr>() can fail for the following reasons:"
3307 #: build/C/man2/sched_setattr.2:293 build/C/man2/sched_setattr.2:310
3313 #: build/C/man2/sched_setattr.2:300
3314 msgid "The buffer specified by I<size> and I<attr> is too small."
3318 #: build/C/man2/sched_setattr.2:306
3320 "I<size> is invalid; that is, it is smaller than the initial version of the "
3321 "I<sched_attr> structure (48 bytes) or larger than the system page size."
3325 #: build/C/man2/sched_setattr.2:310
3326 msgid "In addition, B<sched_setattr>() can fail for the following reasons:"
3330 #: build/C/man2/sched_setattr.2:318
3332 "The buffer specified by I<size> and I<attr> is larger than the kernel "
3333 "structure, and one or more of the excess bytes is nonzero."
3337 #: build/C/man2/sched_setattr.2:318
3343 #: build/C/man2/sched_setattr.2:323
3344 msgid "B<SCHED_DEADLINE> admission control failure, see B<sched>(7)."
3348 #: build/C/man2/sched_setattr.2:339
3350 "I<attr.sched_policy> is not one of the recognized policies; "
3351 "I<attr.sched_flags> contains a flag other than B<SCHED_FLAG_RESET_ON_FORK>; "
3352 "or I<attr.sched_priority> is invalid; or I<attr.sched_policy> is "
3353 "B<SCHED_DEADLINE> and the deadline scheduling parameters in I<attr> are "
3358 #: build/C/man2/sched_setattr.2:342
3359 msgid "The caller does not have appropriate privileges."
3363 #: build/C/man2/sched_setattr.2:348
3365 "The caller's CPU affinity mask does not include all CPUs in the system (see "
3366 "B<sched_setaffinity>(2))."
3369 #. FIXME Add glibc version
3371 #: build/C/man2/sched_setattr.2:351
3372 msgid "These system calls first appeared in Linux 3.14."
3376 #: build/C/man2/sched_setattr.2:353
3377 msgid "These system calls are nonstandard Linux extensions."
3381 #: build/C/man2/sched_setattr.2:369
3383 "B<sched_setattr>() provides a superset of the functionality of "
3384 "B<sched_setscheduler>(2), B<sched_setparam>(2), B<nice>(2), and (other than "
3385 "the ability to set the priority of all processes belonging to a specified "
3386 "user or all processes in a specified group) B<setpriority>(2). "
3387 "Analogously, B<sched_getattr()> provides a superset of the functionality of "
3388 "B<sched_getscheduler>(2), B<sched_getparam>(2), and (partially) "
3389 "B<getpriority>(2)."
3392 #. FIXME patch sent to Peter Zijlstra
3393 #. In Linux versions up to up 3.15,
3394 #. .\" FIXME patch from Peter Zijlstra pending
3395 #. .BR sched_setattr ()
3396 #. allowed a negative
3397 #. .I attr.sched_policy
3400 #: build/C/man2/sched_setattr.2:385
3402 "In Linux versions up to 3.15, B<sched_settattr>() failed with the error "
3403 "B<EFAULT> instead of B<E2BIG> for the case described in ERRORS."
3407 #: build/C/man2/sched_setattr.2:406
3409 "B<nice>(2), B<sched_get_priority_max>(2), B<sched_get_priority_min>(2), "
3410 "B<sched_getaffinity>(2), B<sched_getscheduler>(2), B<sched_getparam>(2), "
3411 "B<sched_rr_get_interval>(2), B<sched_setaffinity>(2), "
3412 "B<sched_setscheduler>(2), B<sched_setparam>(2), B<sched_yield>(2), "
3413 "B<setpriority>(2), B<pthread_getschedparam>(3), B<pthread_setschedparam>(3), "
3414 "B<pthread_setschedprio>(3), B<capabilities>(7), B<cpuset>(7), B<sched>(7)"
3418 #: build/C/man2/sched_setparam.2:30
3420 msgid "SCHED_SETPARAM"
3424 #: build/C/man2/sched_setparam.2:30
3430 #: build/C/man2/sched_setparam.2:33
3431 msgid "sched_setparam, sched_getparam - set and get scheduling parameters"
3435 #: build/C/man2/sched_setparam.2:38
3438 "B<int sched_setparam(pid_t >I<pid>B<, const struct sched_param "
3443 #: build/C/man2/sched_setparam.2:40
3445 msgid "B<int sched_getparam(pid_t >I<pid>B<, struct sched_param *>I<param>B<);>\n"
3449 #: build/C/man2/sched_setparam.2:46
3452 "B<struct sched_param {\n"
3454 " int >I<sched_priority>B<;\n"
3460 #: build/C/man2/sched_setparam.2:60
3462 "B<sched_setparam>() sets the scheduling parameters associated with the "
3463 "scheduling policy for the process identified by I<pid>. If I<pid> is zero, "
3464 "then the parameters of the calling process are set. The interpretation of "
3465 "the argument I<param> depends on the scheduling policy of the process "
3466 "identified by I<pid>. See B<sched>(7) for a description of the scheduling "
3467 "policies supported under Linux."
3471 #: build/C/man2/sched_setparam.2:66
3473 "B<sched_getparam>() retrieves the scheduling parameters for the process "
3474 "identified by I<pid>. If I<pid> is zero, then the parameters of the calling "
3475 "process are retrieved."
3479 #: build/C/man2/sched_setparam.2:75
3481 "B<sched_setparam>() checks the validity of I<param> for the scheduling "
3482 "policy of the thread. The value I<param-E<gt>sched_priority> must lie "
3483 "within the range given by B<sched_get_priority_min>(2) and "
3484 "B<sched_get_priority_max>(2)."
3488 #: build/C/man2/sched_setparam.2:79
3490 "For a discussion of the privileges and resource limits related to scheduling "
3491 "priority and policy, see B<sched>(7)."
3495 #: build/C/man2/sched_setparam.2:87
3497 "POSIX systems on which B<sched_setparam>() and B<sched_getparam>() are "
3498 "available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3502 #: build/C/man2/sched_setparam.2:96
3504 "On success, B<sched_setparam>() and B<sched_getparam>() return 0. On "
3505 "error, -1 is returned, and I<errno> is set appropriately."
3509 #: build/C/man2/sched_setparam.2:104
3510 msgid "Invalid arguments: I<param> is NULL or I<pid> is negative"
3514 #: build/C/man2/sched_setparam.2:109
3516 "(B<sched_setparam>()) The argument I<param> does not make sense for the "
3517 "current scheduling policy."
3521 #: build/C/man2/sched_setparam.2:116
3523 "(B<sched_setparam>()) The calling process does not have appropriate "
3524 "privileges (Linux: does not have the B<CAP_SYS_NICE> capability)."
3528 #: build/C/man2/sched_setparam.2:119
3529 msgid "The process whose ID is I<pid> could not be found."
3533 #: build/C/man2/sched_setparam.2:127
3535 "Scheduling parameters are in fact per-thread attributes on Linux; see "
3540 #: build/C/man2/sched_setparam.2:142
3542 "B<getpriority>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3543 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), "
3544 "B<sched_getscheduler>(2), B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
3545 "B<sched_setattr>(2), B<setpriority>(2), B<capabilities>(7), B<sched>(7)"
3549 #: build/C/man2/sched_setscheduler.2:26
3551 msgid "SCHED_SETSCHEDULER"
3555 #: build/C/man2/sched_setscheduler.2:26
3561 #: build/C/man2/sched_setscheduler.2:30
3563 "sched_setscheduler, sched_getscheduler - set and get scheduling "
3568 #: build/C/man2/sched_setscheduler.2:35
3570 msgid "B<int sched_setscheduler(pid_t >I<pid>B<, int >I<policy>B<,>\n"
3574 #: build/C/man2/sched_setscheduler.2:37
3576 msgid "B< const struct sched_param *>I<param>B<);>\n"
3580 #: build/C/man2/sched_setscheduler.2:39
3582 msgid "B<int sched_getscheduler(pid_t >I<pid>B<);>\n"
3586 #: build/C/man2/sched_setscheduler.2:49
3588 "The B<sched_setscheduler>() system call sets both the scheduling policy and "
3589 "parameters for the thread whose ID is specified in I<pid>. If I<pid> equals "
3590 "zero, the scheduling policy and parameters of the calling thread will be "
3595 #: build/C/man2/sched_setscheduler.2:53
3597 "The scheduling parameters are specified in the I<param> argument, which is a "
3598 "pointer to a structure of the following form:"
3602 #: build/C/man2/sched_setscheduler.2:61
3605 "struct sched_param {\n"
3607 " int sched_priority;\n"
3613 #: build/C/man2/sched_setscheduler.2:69
3615 "In the current implementation, the structure contains only one field, "
3616 "I<sched_priority>. The interpretation of I<param> depends on the selected "
3621 #: build/C/man2/sched_setscheduler.2:90
3622 msgid "For each of the above policies, I<param-E<gt>sched_priority> must be 0."
3626 #: build/C/man2/sched_setscheduler.2:116
3628 "For each of the above policies, I<param-E<gt>sched_priority> specifies a "
3629 "scheduling priority for the thread. This is a number in the range returned "
3630 "by calling B<sched_get_priority_min>(2) and B<sched_get_priority_min>(2) "
3631 "with the specified I<policy>. On Linux, these system calls return, "
3632 "respectively, 1 and 99."
3636 #: build/C/man2/sched_setscheduler.2:129
3638 "Since Linux 2.6.32, the B<SCHED_RESET_ON_FORK> flag can be ORed in I<policy> "
3639 "when calling B<sched_setscheduler>(). As a result of including this flag, "
3640 "children created by B<fork>(2) do not inherit privileged scheduling "
3641 "policies. See B<sched>(7) for details."
3645 #: build/C/man2/sched_setscheduler.2:135
3647 "B<sched_getscheduler>() returns the current scheduling policy of the thread "
3648 "identified by I<pid>. If I<pid> equals zero, the policy of the calling "
3649 "thread will be retrieved."
3653 #: build/C/man2/sched_setscheduler.2:145
3655 "On success, B<sched_setscheduler>() returns zero. On success, "
3656 "B<sched_getscheduler>() returns the policy for the thread (a nonnegative "
3657 "integer). On error, both calls return -1, and I<errno> is set "
3662 #: build/C/man2/sched_setscheduler.2:153
3663 msgid "Invalid arguments: I<pid> is negative or I<param> is NULL."
3667 #: build/C/man2/sched_setscheduler.2:158
3668 msgid "(B<sched_setscheduler>()) I<policy> is not one of the recognized policies."
3672 #: build/C/man2/sched_setscheduler.2:164
3674 "(B<sched_setscheduler>()) I<param> does not make sense for the specified "
3679 #: build/C/man2/sched_setscheduler.2:167
3680 msgid "The calling thread does not have appropriate privileges."
3684 #: build/C/man2/sched_setscheduler.2:173
3686 "POSIX.1-2001 (but see BUGS below). The B<SCHED_BATCH> and B<SCHED_IDLE> "
3687 "policies are Linux-specific."
3691 #: build/C/man2/sched_setscheduler.2:177
3693 "Further details of the semantics of all of the above \"normal\" and "
3694 "\"real-time\" scheduling policies can be found in B<sched>(7)."
3698 #: build/C/man2/sched_setscheduler.2:185
3700 "POSIX systems on which B<sched_setscheduler>() and B<sched_getscheduler>() "
3701 "are available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3705 #: build/C/man2/sched_setscheduler.2:193
3707 "POSIX.1 does not detail the permissions that an unprivileged thread requires "
3708 "in order to call B<sched_setscheduler>(), and details vary across systems. "
3709 "For example, the Solaris 7 manual page says that the real or effective user "
3710 "ID of the caller must match the real user ID or the save set-user-ID of the "
3715 #: build/C/man2/sched_setscheduler.2:214
3717 "The scheduling policy and parameters are in fact per-thread attributes on "
3718 "Linux. The value returned from a call to B<gettid>(2) can be passed in the "
3719 "argument I<pid>. Specifying I<pid> as 0 will operate on the attributes of "
3720 "the calling thread, and passing the value returned from a call to "
3721 "B<getpid>(2) will operate on the attributes of the main thread of the "
3722 "thread group. (If you are using the POSIX threads API, then use "
3723 "B<pthread_setschedparam>(3), B<pthread_getschedparam>(3), and "
3724 "B<pthread_setschedprio>(3), instead of the B<sched_*>(2) system calls.)"
3728 #: build/C/man2/sched_setscheduler.2:222
3730 "POSIX says that on success, B<sched_setscheduler>() should return the "
3731 "previous scheduling policy. Linux B<sched_setscheduler>() does not conform "
3732 "to this requirement, since it always returns 0 on success."
3736 #: build/C/man2/sched_setscheduler.2:240
3738 "B<nice>(2), B<sched_get_priority_max>(2), B<sched_get_priority_min>(2), "
3739 "B<sched_getaffinity>(2), B<sched_getattr>(2), B<sched_getparam>(2), "
3740 "B<sched_rr_get_interval>(2), B<sched_setaffinity>(2), B<sched_setattr>(2), "
3741 "B<sched_setparam>(2), B<sched_yield>(2), B<setpriority>(2), "
3742 "B<capabilities>(7), B<cpuset>(7), B<sched>(7)"
3746 #: build/C/man2/sched_yield.2:29
3752 #: build/C/man2/sched_yield.2:32
3753 msgid "sched_yield - yield the processor"
3757 #: build/C/man2/sched_yield.2:36
3758 msgid "B<int sched_yield(void);>"
3762 #: build/C/man2/sched_yield.2:41
3764 "B<sched_yield>() causes the calling thread to relinquish the CPU. The "
3765 "thread is moved to the end of the queue for its static priority and a new "
3766 "thread gets to run."
3770 #: build/C/man2/sched_yield.2:48
3772 "On success, B<sched_yield>() returns 0. On error, -1 is returned, and "
3773 "I<errno> is set appropriately."
3777 #: build/C/man2/sched_yield.2:52
3778 msgid "In the Linux implementation, B<sched_yield>() always succeeds."
3782 #: build/C/man2/sched_yield.2:59
3784 "If the calling thread is the only thread in the highest priority list at "
3785 "that time, it will continue to run after a call to B<sched_yield>()."
3789 #: build/C/man2/sched_yield.2:66
3791 "POSIX systems on which B<sched_yield>() is available define "
3792 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3796 #: build/C/man2/sched_yield.2:79
3798 "Strategic calls to B<sched_yield>() can improve performance by giving other "
3799 "threads or processes a chance to run when (heavily) contended resources "
3800 "(e.g., mutexes) have been released by the caller. Avoid calling "
3801 "B<sched_yield>() unnecessarily or inappropriately (e.g., when resources "
3802 "needed by other schedulable threads are still held by the caller), since "
3803 "doing so will result in unnecessary context switches, which will degrade "
3804 "system performance."
3808 #: build/C/man2/setns.2:8
3814 #: build/C/man2/setns.2:8
3820 #: build/C/man2/setns.2:11
3821 msgid "setns - reassociate thread with a namespace"
3825 #: build/C/man2/setns.2:17
3827 msgid "B<int setns(int >I<fd>B<, int >I<nstype>B<);>\n"
3831 #: build/C/man2/setns.2:21
3833 "Given a file descriptor referring to a namespace, reassociate the calling "
3834 "thread with that namespace."
3838 #: build/C/man2/setns.2:34
3840 "The I<fd> argument is a file descriptor referring to one of the namespace "
3841 "entries in a I</proc/[pid]/ns/> directory; see B<proc>(5) for further "
3842 "information on I</proc/[pid]/ns/>. The calling thread will be reassociated "
3843 "with the corresponding namespace, subject to any constraints imposed by the "
3844 "I<nstype> argument."
3848 #: build/C/man2/setns.2:40
3850 "The I<nstype> argument specifies which type of namespace the calling thread "
3851 "may be reassociated with. This argument can have one of the following "
3856 #: build/C/man2/setns.2:40
3862 #: build/C/man2/setns.2:43
3863 msgid "Allow any type of namespace to be joined."
3867 #: build/C/man2/setns.2:43
3869 msgid "B<CLONE_NEWIPC>"
3873 #: build/C/man2/setns.2:47
3874 msgid "I<fd> must refer to an IPC namespace."
3878 #: build/C/man2/setns.2:47
3880 msgid "B<CLONE_NEWNET>"
3884 #: build/C/man2/setns.2:51
3885 msgid "I<fd> must refer to a network namespace."
3889 #: build/C/man2/setns.2:51
3891 msgid "B<CLONE_NEWUTS>"
3895 #: build/C/man2/setns.2:55
3896 msgid "I<fd> must refer to a UTS namespace."
3900 #: build/C/man2/setns.2:70
3902 "Specifying I<nstype> as 0 suffices if the caller knows (or does not care) "
3903 "what type of namespace is referred to by I<fd>. Specifying a nonzero value "
3904 "for I<nstype> is useful if the caller does not know what type of namespace "
3905 "is referred to by I<fd> and wants to ensure that the namespace is of a "
3906 "particular type. (The caller might not know the type of the namespace "
3907 "referred to by I<fd> if the file descriptor was opened by another process "
3908 "and, for example, passed to the caller via a UNIX domain socket.)"
3912 #: build/C/man2/setns.2:77
3914 "On success, I<setns>() returns 0. On failure, -1 is returned and I<errno> "
3915 "is set to indicate the error."
3919 #: build/C/man2/setns.2:82
3920 msgid "I<fd> is not a valid file descriptor."
3924 #: build/C/man2/setns.2:89
3926 "I<fd> refers to a namespace whose type does not match that specified in "
3927 "I<nstype>, or there is problem with reassociating the the thread with the "
3928 "specified namespace."
3932 #: build/C/man2/setns.2:92
3933 msgid "Cannot allocate sufficient memory to change the specified namespace."
3937 #: build/C/man2/setns.2:97
3939 "The calling thread did not have the required privilege (B<CAP_SYS_ADMIN>) "
3940 "for this operation."
3944 #: build/C/man2/setns.2:102
3946 "The B<setns>() system call first appeared in Linux in kernel 3.0; library "
3947 "support was added to glibc in version 2.14."
3951 #: build/C/man2/setns.2:106
3952 msgid "The B<setns>() system call is Linux-specific."
3956 #: build/C/man2/setns.2:112
3958 "Not all of the attributes that can be shared when a new thread is created "
3959 "using B<clone>(2) can be changed using B<setns>()."
3963 #: build/C/man2/setns.2:121
3965 "The program below takes two or more arguments. The first argument specifies "
3966 "the pathname of a namespace file in an existing I</proc/[pid]/ns/> "
3967 "directory. The remaining arguments specify a command and its arguments. "
3968 "The program opens the namespace file, joins that namespace using B<setns>(), "
3969 "and executes the specified command inside that namespace."
3973 #: build/C/man2/setns.2:131
3975 "The following shell session demonstrates the use of this program (compiled "
3976 "as a binary named I<ns_exec>) in conjunction with the B<CLONE_NEWUTS> "
3977 "example program in the B<clone>(2) man page (complied as a binary named "
3982 #: build/C/man2/setns.2:139
3984 "We begin by executing the example program in B<clone>(2) in the "
3985 "background. That program creates a child in a separate UTS namespace. The "
3986 "child changes the hostname in its namespace, and then both processes display "
3987 "the hostnames in their UTS namespaces, so that we can see that they are "
3992 #: build/C/man2/setns.2:151
3995 "$ B<su> # Need privilege for namespace operations\n"
3997 "# B<./newuts bizarro &>\n"
3999 "clone() returned 3550\n"
4000 "uts.nodename in child: bizarro\n"
4001 "uts.nodename in parent: antero\n"
4002 "# B<uname -n> # Verify hostname in the shell\n"
4007 #: build/C/man2/setns.2:158
4009 "We then run the program shown below, using it to execute a shell. Inside "
4010 "that shell, we verify that the hostname is the one set by the child created "
4011 "by the first program:"
4015 #: build/C/man2/setns.2:164
4018 "# B<./ns_exec /proc/3550/ns/uts /bin/bash>\n"
4019 "# B<uname -n> # Executed in shell started by ns_exec\n"
4024 #: build/C/man2/setns.2:174
4027 "#define _GNU_SOURCE\n"
4028 "#include E<lt>fcntl.hE<gt>\n"
4029 "#include E<lt>sched.hE<gt>\n"
4030 "#include E<lt>unistd.hE<gt>\n"
4031 "#include E<lt>stdlib.hE<gt>\n"
4032 "#include E<lt>stdio.hE<gt>\n"
4036 #: build/C/man2/setns.2:182
4040 "main(int argc, char *argv[])\n"
4046 #: build/C/man2/setns.2:187
4049 " if (argc E<lt> 3) {\n"
4050 " fprintf(stderr, \"%s /proc/PID/ns/FILE cmd args...\\en\", "
4052 " exit(EXIT_FAILURE);\n"
4057 #: build/C/man2/setns.2:191
4060 " fd = open(argv[1], O_RDONLY); /* Get descriptor for namespace */\n"
4062 " errExit(\"open\");\n"
4066 #: build/C/man2/setns.2:194
4069 " if (setns(fd, 0) == -1) /* Join that namespace */\n"
4070 " errExit(\"setns\");\n"
4074 #: build/C/man2/setns.2:198
4077 " execvp(argv[2], &argv[2]); /* Execute a command in namespace */\n"
4078 " errExit(\"execvp\");\n"
4083 #: build/C/man2/setns.2:205
4084 msgid "B<clone>(2), B<fork>(2), B<vfork>(2), B<proc>(5), B<unix>(7)"
4088 #: build/C/man2/unshare.2:20
4094 #: build/C/man2/unshare.2:20
4100 #: build/C/man2/unshare.2:23
4101 msgid "unshare - disassociate parts of the process execution context"
4105 #: build/C/man2/unshare.2:28
4107 msgid "B<int unshare(int >I<flags>B<);>\n"
4111 #: build/C/man2/unshare.2:36
4112 msgid "B<unshare>():"
4116 #: build/C/man2/unshare.2:62
4118 "B<unshare>() allows a process to disassociate parts of its execution "
4119 "context that are currently being shared with other processes. Part of the "
4120 "execution context, such as the mount namespace, is shared implicitly when a "
4121 "new process is created using B<fork>(2) or B<vfork>(2), while other parts, "
4122 "such as virtual memory, may be shared by explicit request when creating a "
4123 "process using B<clone>(2)."
4127 #: build/C/man2/unshare.2:67
4129 "The main use of B<unshare>() is to allow a process to control its shared "
4130 "execution context without creating a new process."
4134 #: build/C/man2/unshare.2:74
4136 "The I<flags> argument is a bit mask that specifies which parts of the "
4137 "execution context should be unshared. This argument is specified by ORing "
4138 "together zero or more of the following constants:"
4142 #: build/C/man2/unshare.2:74
4144 msgid "B<CLONE_FILES>"
4148 #: build/C/man2/unshare.2:82
4150 "Reverse the effect of the B<clone>(2) B<CLONE_FILES> flag. Unshare the "
4151 "file descriptor table, so that the calling process no longer shares its file "
4152 "descriptors with any other process."
4156 #: build/C/man2/unshare.2:82
4162 #: build/C/man2/unshare.2:96
4164 "Reverse the effect of the B<clone>(2) B<CLONE_FS> flag. Unshare filesystem "
4165 "attributes, so that the calling process no longer shares its root directory "
4166 "(B<chroot>(2)), current directory (B<chdir>(2)), or umask (B<umask>(2)) "
4167 "attributes with any other process."
4171 #: build/C/man2/unshare.2:113
4173 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWIPC> flag. "
4174 "Unshare the System\\ V IPC namespace, so that the calling process has a "
4175 "private copy of the System\\ V IPC namespace which is not shared with any "
4176 "other process. Specifying this flag automatically implies B<CLONE_SYSVSEM> "
4177 "as well. Use of B<CLONE_NEWIPC> requires the B<CAP_SYS_ADMIN> capability."
4181 #: build/C/man2/unshare.2:128
4183 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNET> flag. "
4184 "Unshare the network namespace, so that the calling process is moved into a "
4185 "new network namespace which is not shared with any previously existing "
4186 "process. Use of B<CLONE_NEWNET> requires the B<CAP_SYS_ADMIN> capability."
4190 #: build/C/man2/unshare.2:128
4192 msgid "B<CLONE_NEWNS>"
4195 #. These flag name are inconsistent:
4196 #. CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
4197 #. CLONE_FS, and CLONE_FILES reverse the action of the clone()
4198 #. flags of the same name.
4200 #: build/C/man2/unshare.2:149
4202 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNS> flag. "
4203 "Unshare the mount namespace, so that the calling process has a private copy "
4204 "of its namespace which is not shared with any other process. Specifying "
4205 "this flag automatically implies B<CLONE_FS> as well. Use of B<CLONE_NEWNS> "
4206 "requires the B<CAP_SYS_ADMIN> capability."
4210 #: build/C/man2/unshare.2:163
4212 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWUTS> flag. "
4213 "Unshare the UTS IPC namespace, so that the calling process has a private "
4214 "copy of the UTS namespace which is not shared with any other process. Use "
4215 "of B<CLONE_NEWUTS> requires the B<CAP_SYS_ADMIN> capability."
4219 #: build/C/man2/unshare.2:163
4221 msgid "B<CLONE_SYSVSEM> (since Linux 2.6.26)"
4224 #. commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
4225 #. As at 2.6.16, the following forced implications also apply,
4226 #. although the relevant flags are not yet implemented.
4227 #. If CLONE_THREAD is set force CLONE_VM.
4228 #. If CLONE_VM is set, force CLONE_SIGHAND.
4229 #. CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
4230 #. (i.e., current->signal->count > 1), force CLONE_THREAD.
4232 #. FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
4235 #. Reverse the effect of the
4240 #. is also implicitly set by
4242 #. and can be reversed using this
4245 #. Unshare virtual memory, so that the calling process no
4246 #. longer shares its virtual address space with any other process.
4248 #: build/C/man2/unshare.2:200
4250 "This flag reverses the effect of the B<clone>(2) B<CLONE_SYSVSEM> flag. "
4251 "Unshare System\\ V semaphore undo values, so that the calling process has a "
4252 "private copy which is not shared with any other process. Use of "
4253 "B<CLONE_SYSVSEM> requires the B<CAP_SYS_ADMIN> capability."
4257 #: build/C/man2/unshare.2:207
4259 "If I<flags> is specified as zero, then B<unshare>() is a no-op; no changes "
4260 "are made to the calling process's execution context."
4264 #: build/C/man2/unshare.2:212
4266 "On success, zero returned. On failure, -1 is returned and I<errno> is set "
4267 "to indicate the error."
4271 #: build/C/man2/unshare.2:217
4272 msgid "An invalid bit was specified in I<flags>."
4276 #: build/C/man2/unshare.2:221
4278 "Cannot allocate sufficient memory to copy parts of caller's context that "
4279 "need to be unshared."
4283 #: build/C/man2/unshare.2:224
4284 msgid "The calling process did not have the required privileges for this operation."
4288 #: build/C/man2/unshare.2:228
4289 msgid "The B<unshare>() system call was added to Linux in kernel 2.6.16."
4293 #: build/C/man2/unshare.2:232
4294 msgid "The B<unshare>() system call is Linux-specific."
4297 #. FIXME all of the following needs to be reviewed for the current kernel
4298 #. However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
4299 #. was not specified when doing clone(); i.e., unsharing
4300 #. signal handlers is permitted if we are not actually
4301 #. sharing signal handlers. mtk
4302 #. However, we can do unshare(CLONE_VM) if CLONE_VM
4303 #. was not specified when doing clone(); i.e., unsharing
4304 #. virtual memory is permitted if we are not actually
4305 #. sharing virtual memory. mtk
4309 #. The current implementation of unshare does not allow unsharing of
4310 #. signals and signal handlers. Signals are complex to begin with and
4311 #. to unshare signals and/or signal handlers of a currently running
4312 #. process is even more complex. If in the future there is a specific
4313 #. need to allow unsharing of signals and/or signal handlers, it can
4314 #. be incrementally added to unshare without affecting legacy
4315 #. applications using unshare.
4317 #: build/C/man2/unshare.2:266
4319 "Not all of the process attributes that can be shared when a new process is "
4320 "created using B<clone>(2) can be unshared using B<unshare>(). In "
4321 "particular, as at kernel 3.8, B<unshare>() does not implement flags that "
4322 "reverse the effects of B<CLONE_SIGHAND>, B<CLONE_THREAD>, or B<CLONE_VM>. "
4323 "Such functionality may be added in the future, if required."
4327 #: build/C/man2/unshare.2:272
4328 msgid "B<clone>(2), B<fork>(2), B<kcmp>(2), B<setns>(2), B<vfork>(2)"
4332 #: build/C/man2/unshare.2:275
4333 msgid "I<Documentation/unshare.txt> in the Linux kernel source tree"
4337 #: build/C/man7/sched.7:32
4343 #: build/C/man7/sched.7:35
4344 msgid "sched - overview of scheduling APIs"
4348 #: build/C/man7/sched.7:36
4354 #: build/C/man7/sched.7:38
4355 msgid "The Linux scheduling APIs are as follows:"
4359 #: build/C/man7/sched.7:38
4361 msgid "B<sched_setscheduler>(2)"
4365 #: build/C/man7/sched.7:41
4366 msgid "Set the scheduling policy and parameters of a specified thread."
4370 #: build/C/man7/sched.7:41
4372 msgid "B<sched_getscheduler>(2)"
4376 #: build/C/man7/sched.7:44
4377 msgid "Return the scheduling policy of a specified thread."
4381 #: build/C/man7/sched.7:44
4383 msgid "B<sched_setparam>(2)"
4387 #: build/C/man7/sched.7:47
4388 msgid "Set the scheduling parameters of a specified thread."
4392 #: build/C/man7/sched.7:47
4394 msgid "B<sched_getparam>(2)"
4398 #: build/C/man7/sched.7:50
4399 msgid "Fetch the scheduling parameters of a specified thread."
4403 #: build/C/man7/sched.7:50
4405 msgid "B<sched_get_priority_max>(2)"
4409 #: build/C/man7/sched.7:53
4410 msgid "Return the minimum priority available in a specified scheduling policy."
4414 #: build/C/man7/sched.7:53
4416 msgid "B<sched_get_priority_min>(2)"
4420 #: build/C/man7/sched.7:56
4421 msgid "Return the maximum priority available in a specified scheduling policy."
4425 #: build/C/man7/sched.7:56
4427 msgid "B<sched_rr_get_interval>(2)"
4431 #: build/C/man7/sched.7:60
4433 "Fetch the quantum used for threads that are scheduled under the "
4434 "\"round-robin\" scheduling policy."
4438 #: build/C/man7/sched.7:60
4440 msgid "B<sched_yield>(2)"
4444 #: build/C/man7/sched.7:64
4446 "Cause the caller to relinquish the CPU, so that some other thread be "
4451 #: build/C/man7/sched.7:64
4453 msgid "B<sched_setaffinity>(2)"
4457 #: build/C/man7/sched.7:68
4458 msgid "(Linux-specific) Set the CPU affinity of a specified thread."
4462 #: build/C/man7/sched.7:68
4464 msgid "B<sched_getaffinity>(2)"
4468 #: build/C/man7/sched.7:72
4469 msgid "(Linux-specific) Get the CPU affinity of a specified thread."
4473 #: build/C/man7/sched.7:72
4475 msgid "B<sched_setattr>(2)"
4479 #: build/C/man7/sched.7:79
4481 "Set the scheduling policy and parameters of a specified thread. This "
4482 "(Linux-specific) system call provides a superset of the functionality of "
4483 "B<sched_setscheduler>(2) and B<sched_setparam>(2)."
4487 #: build/C/man7/sched.7:79
4489 msgid "B<sched_getattr>(2)"
4493 #: build/C/man7/sched.7:87
4495 "Fetch the scheduling policy and parameters of a specified thread. This "
4496 "(Linux-specific) system call provides a superset of the functionality of "
4497 "B<sched_getscheduler>(2) and B<sched_getparam>(2)."
4501 #: build/C/man7/sched.7:87
4503 msgid "Scheduling policies"
4507 #: build/C/man7/sched.7:95
4509 "The scheduler is the kernel component that decides which runnable thread "
4510 "will be executed by the CPU next. Each thread has an associated scheduling "
4511 "policy and a I<static> scheduling priority, I<sched_priority>. The "
4512 "scheduler makes its decisions based on knowledge of the scheduling policy "
4513 "and static priority of all threads on the system."
4517 #: build/C/man7/sched.7:100
4519 "For threads scheduled under one of the normal scheduling policies "
4520 "(B<SCHED_OTHER>, B<SCHED_IDLE>, B<SCHED_BATCH>), I<sched_priority> is not "
4521 "used in scheduling decisions (it must be specified as 0)."
4525 #: build/C/man7/sched.7:114
4527 "Processes scheduled under one of the real-time policies (B<SCHED_FIFO>, "
4528 "B<SCHED_RR>) have a I<sched_priority> value in the range 1 (low) to 99 "
4529 "(high). (As the numbers imply, real-time threads always have higher "
4530 "priority than normal threads.) Note well: POSIX.1-2001 requires an "
4531 "implementation to support only a minimum 32 distinct priority levels for the "
4532 "real-time policies, and some systems supply just this minimum. Portable "
4533 "programs should use B<sched_get_priority_min>(2) and "
4534 "B<sched_get_priority_max>(2) to find the range of priorities supported for "
4535 "a particular policy."
4539 #: build/C/man7/sched.7:120
4541 "Conceptually, the scheduler maintains a list of runnable threads for each "
4542 "possible I<sched_priority> value. In order to determine which thread runs "
4543 "next, the scheduler looks for the nonempty list with the highest static "
4544 "priority and selects the thread at the head of this list."
4548 #: build/C/man7/sched.7:124
4550 "A thread's scheduling policy determines where it will be inserted into the "
4551 "list of threads with equal static priority and how it will move inside this "
4556 #: build/C/man7/sched.7:132
4558 "All scheduling is preemptive: if a thread with a higher static priority "
4559 "becomes ready to run, the currently running thread will be preempted and "
4560 "returned to the wait list for its static priority level. The scheduling "
4561 "policy determines the ordering only within the list of runnable threads with "
4562 "equal static priority."
4566 #: build/C/man7/sched.7:132
4568 msgid "SCHED_FIFO: First in-first out scheduling"
4572 #: build/C/man7/sched.7:141
4574 "B<SCHED_FIFO> can be used only with static priorities higher than 0, which "
4575 "means that when a B<SCHED_FIFO> threads becomes runnable, it will always "
4576 "immediately preempt any currently running B<SCHED_OTHER>, B<SCHED_BATCH>, or "
4577 "B<SCHED_IDLE> thread. B<SCHED_FIFO> is a simple scheduling algorithm "
4578 "without time slicing. For threads scheduled under the B<SCHED_FIFO> policy, "
4579 "the following rules apply:"
4583 #: build/C/man7/sched.7:141 build/C/man7/sched.7:146 build/C/man7/sched.7:149 build/C/man7/sched.7:164 build/C/man7/sched.7:413 build/C/man7/sched.7:422 build/C/man7/sched.7:445 build/C/man7/sched.7:453 build/C/man7/sched.7:492 build/C/man7/sched.7:500 build/C/man7/sched.7:505 build/C/man7/sched.7:510
4589 #: build/C/man7/sched.7:146
4591 "A B<SCHED_FIFO> thread that has been preempted by another thread of higher "
4592 "priority will stay at the head of the list for its priority and will resume "
4593 "execution as soon as all threads of higher priority are blocked again."
4597 #: build/C/man7/sched.7:149
4599 "When a B<SCHED_FIFO> thread becomes runnable, it will be inserted at the end "
4600 "of the list for its priority."
4603 #. In 2.2.x and 2.4.x, the thread is placed at the front of the queue
4604 #. In 2.0.x, the Right Thing happened: the thread went to the back -- MTK
4606 #: build/C/man7/sched.7:164
4608 "A call to B<sched_setscheduler>(2), B<sched_setparam>(2), or "
4609 "B<sched_setattr>(2) will put the B<SCHED_FIFO> (or B<SCHED_RR>) thread "
4610 "identified by I<pid> at the start of the list if it was runnable. As a "
4611 "consequence, it may preempt the currently running thread if it has the same "
4612 "priority. (POSIX.1-2001 specifies that the thread should go to the end of "
4617 #: build/C/man7/sched.7:168
4618 msgid "A thread calling B<sched_yield>(2) will be put at the end of the list."
4622 #: build/C/man7/sched.7:172
4624 "No other events will move a thread scheduled under the B<SCHED_FIFO> policy "
4625 "in the wait list of runnable threads with equal static priority."
4629 #: build/C/man7/sched.7:177
4631 "A B<SCHED_FIFO> thread runs until either it is blocked by an I/O request, it "
4632 "is preempted by a higher priority thread, or it calls B<sched_yield>(2)."
4636 #: build/C/man7/sched.7:177
4638 msgid "SCHED_RR: Round-robin scheduling"
4641 #. On Linux 2.4, the length of the RR interval is influenced
4642 #. by the process nice value -- MTK
4644 #: build/C/man7/sched.7:196
4646 "B<SCHED_RR> is a simple enhancement of B<SCHED_FIFO>. Everything described "
4647 "above for B<SCHED_FIFO> also applies to B<SCHED_RR>, except that each thread "
4648 "is allowed to run only for a maximum time quantum. If a B<SCHED_RR> thread "
4649 "has been running for a time period equal to or longer than the time quantum, "
4650 "it will be put at the end of the list for its priority. A B<SCHED_RR> "
4651 "thread that has been preempted by a higher priority thread and subsequently "
4652 "resumes execution as a running thread will complete the unexpired portion of "
4653 "its round-robin time quantum. The length of the time quantum can be "
4654 "retrieved using B<sched_rr_get_interval>(2)."
4658 #: build/C/man7/sched.7:196
4660 msgid "SCHED_DEADLINE: Sporadic task model deadline scheduling"
4664 #: build/C/man7/sched.7:208
4666 "Since version 3.14, Linux provides a deadline scheduling policy "
4667 "(B<SCHED_DEADLINE>). This policy is currently implemented using GEDF "
4668 "(Global Earliest Deadline First) in conjunction with CBS (Constant "
4669 "Bandwidth Server). To set and fetch this policy and associated attributes, "
4670 "one must use the Linux-specific B<sched_setattr>(2) and B<sched_getattr>(2) "
4675 #: build/C/man7/sched.7:226
4677 "A sporadic task is one that has a sequence of jobs, where each job is "
4678 "activated at most once per period. Each job also has a I<relative "
4679 "deadline>, before which it should finish execution, and a I<computation "
4680 "time>, which is the CPU time necessary for executing the job. The moment "
4681 "when a task wakes up because a new job has to be executed is called the "
4682 "I<arrival time> (also referred to as the request time or release time). The "
4683 "I<start time> is the time at which a task starts its execution. The "
4684 "I<absolute deadline> is thus obtained by adding the relative deadline to the "
4689 #: build/C/man7/sched.7:228
4690 msgid "The following diagram clarifies these terms:"
4694 #: build/C/man7/sched.7:239
4697 "arrival/wakeup absolute deadline\n"
4701 "-----x--------xooooooooooooooooo--------x--------x---\n"
4702 " |E<lt>- comp. time -E<gt>|\n"
4703 " |E<lt>------- relative deadline ------E<gt>|\n"
4704 " |E<lt>-------------- period -------------------E<gt>|\n"
4708 #: build/C/man7/sched.7:258
4710 "When setting a B<SCHED_DEADLINE> policy for a thread using "
4711 "B<sched_setattr>(2), one can specify three parameters: I<Runtime>, "
4712 "I<Deadline>, and I<Period>. These parameters do not necessarily correspond "
4713 "to the aforementioned terms: usual practice is to set Runtime to something "
4714 "bigger than the average computation time (or worst-case execution time for "
4715 "hard real-time tasks), Deadline to the relative deadline, and Period to the "
4716 "period of the task. Thus, for B<SCHED_DEADLINE> scheduling, we have:"
4720 #: build/C/man7/sched.7:269
4723 "arrival/wakeup absolute deadline\n"
4727 "-----x--------xooooooooooooooooo--------x--------x---\n"
4728 " |E<lt>-- Runtime -------E<gt>|\n"
4729 " |E<lt>----------- Deadline -----------E<gt>|\n"
4730 " |E<lt>-------------- Period -------------------E<gt>|\n"
4733 #. FIXME It looks as though specifying sched_period as 0 means
4734 #. "make sched_period the same as sched_deadline", right?
4735 #. This needs to be documented.
4737 #: build/C/man7/sched.7:289
4739 "The three deadline-scheduling parameters correspond to the I<sched_runtime>, "
4740 "I<sched_deadline>, and I<sched_period> fields of the I<sched_attr> "
4741 "structure; see B<sched_setattr>(2). These fields express value in "
4742 "nanoseconds. If I<sched_period> is specified as 0, then it is made the same "
4743 "as I<sched_deadline>."
4747 #: build/C/man7/sched.7:291
4748 msgid "The kernel requires that:"
4752 #: build/C/man7/sched.7:293
4754 msgid " sched_runtime E<lt>= sched_deadline E<lt>= sched_period\n"
4757 #. See __checkparam_dl in kernel/sched/core.c
4759 #: build/C/man7/sched.7:303
4761 "In addition, under the current implementation, all of the parameter values "
4762 "must be at least 1024 (i.e., just over one microsecond, which is the "
4763 "resolution of the implementation), and less than 2^63. If any of these "
4764 "checks fails, B<sched_setattr>(2) fails with the error B<EINVAL>."
4768 #: build/C/man7/sched.7:306
4770 "The CBS guarantees non-interference between tasks, by throttling threads "
4771 "that attempt to over-run their specified Runtime."
4775 #: build/C/man7/sched.7:319
4777 "To ensure deadline scheduling guarantees, the kernel must prevent situations "
4778 "where the set of B<SCHED_DEADLINE> threads is not feasible (schedulable) "
4779 "within the given constraints. The kernel thus performs an admittance test "
4780 "when setting or changing B<SCHED_DEADLINE> policy and attributes. This "
4781 "admission test calculates whether the change is feasible; if it is not "
4782 "B<sched_setattr>(2) fails with the error B<EBUSY>."
4786 #: build/C/man7/sched.7:325
4788 "For example, it is required (but not necessarily sufficient) for the total "
4789 "utilization to be less than or equal to the total number of CPUs available, "
4790 "where, since each thread can maximally run for Runtime per Period, that "
4791 "thread's utilization is its Runtime divided by its Period."
4795 #: build/C/man7/sched.7:336
4797 "In order to fulfil the guarantees that are made when a thread is admitted to "
4798 "the B<SCHED_DEADLINE> policy, B<SCHED_DEADLINE> threads are the highest "
4799 "priority (user controllable) threads in the system; if any B<SCHED_DEADLINE> "
4800 "thread is runnable, it will preempt any thread scheduled under one of the "
4805 #: build/C/man7/sched.7:344
4807 "A call to B<fork>(2) by a thread scheduled under the B<SCHED_DEADLINE> "
4808 "policy will fail with the error B<EAGAIN>, unless the thread has its "
4809 "reset-on-fork flag set (see below)."
4813 #. FIXME Calling sched_getparam() on a SCHED_DEADLINE thread
4814 #. fails with EINVAL, but sched_getscheduler() succeeds.
4815 #. Is that intended? (Why?)
4817 #: build/C/man7/sched.7:356
4819 "A B<SCHED_DEADLINE> thread that calls B<sched_yield>(2) will yield the "
4820 "current job and wait for a new period to begin."
4824 #: build/C/man7/sched.7:356
4826 msgid "SCHED_OTHER: Default Linux time-sharing scheduling"
4830 #: build/C/man7/sched.7:373
4832 "B<SCHED_OTHER> can be used at only static priority 0. B<SCHED_OTHER> is the "
4833 "standard Linux time-sharing scheduler that is intended for all threads that "
4834 "do not require the special real-time mechanisms. The thread to run is "
4835 "chosen from the static priority 0 list based on a I<dynamic> priority that "
4836 "is determined only inside this list. The dynamic priority is based on the "
4837 "nice value (set by B<nice>(2), B<setpriority>(2), or B<sched_setattr>(2)) "
4838 "and increased for each time quantum the thread is ready to run, but denied "
4839 "to run by the scheduler. This ensures fair progress among all "
4840 "B<SCHED_OTHER> threads."
4844 #: build/C/man7/sched.7:373
4846 msgid "SCHED_BATCH: Scheduling batch processes"
4850 #: build/C/man7/sched.7:385
4852 "(Since Linux 2.6.16.) B<SCHED_BATCH> can be used only at static priority "
4853 "0. This policy is similar to B<SCHED_OTHER> in that it schedules the thread "
4854 "according to its dynamic priority (based on the nice value). The difference "
4855 "is that this policy will cause the scheduler to always assume that the "
4856 "thread is CPU-intensive. Consequently, the scheduler will apply a small "
4857 "scheduling penalty with respect to wakeup behaviour, so that this thread is "
4858 "mildly disfavored in scheduling decisions."
4861 #. The following paragraph is drawn largely from the text that
4862 #. accompanied Ingo Molnar's patch for the implementation of
4864 #. commit b0a9499c3dd50d333e2aedb7e894873c58da3785
4866 #: build/C/man7/sched.7:395
4868 "This policy is useful for workloads that are noninteractive, but do not want "
4869 "to lower their nice value, and for workloads that want a deterministic "
4870 "scheduling policy without interactivity causing extra preemptions (between "
4871 "the workload's tasks)."
4875 #: build/C/man7/sched.7:395
4877 msgid "SCHED_IDLE: Scheduling very low priority jobs"
4881 #: build/C/man7/sched.7:399
4883 "(Since Linux 2.6.23.) B<SCHED_IDLE> can be used only at static priority 0; "
4884 "the process nice value has no influence for this policy."
4888 #: build/C/man7/sched.7:407
4890 "This policy is intended for running jobs at extremely low priority (lower "
4891 "even than a +19 nice value with the B<SCHED_OTHER> or B<SCHED_BATCH> "
4896 #: build/C/man7/sched.7:407
4898 msgid "Resetting scheduling policy for child processes"
4902 #: build/C/man7/sched.7:413
4904 "Each thread has a reset-on-fork scheduling flag. When this flag is set, "
4905 "children created by B<fork>(2) do not inherit privileged scheduling "
4906 "policies. The reset-on-fork flag can be set by either:"
4910 #: build/C/man7/sched.7:422
4912 "ORing the B<SCHED_RESET_ON_FORK> flag into the I<policy> argument when "
4913 "calling B<sched_setscheduler>(2) (since Linux 2.6.32); or"
4917 #: build/C/man7/sched.7:429
4919 "specifying the B<SCHED_FLAG_RESET_ON_FORK> flag in I<attr.sched_flags> when "
4920 "calling B<sched_setattr>(2)."
4924 #: build/C/man7/sched.7:435
4926 "Note that the constants used with these two APIs have different names. The "
4927 "state of the reset-on-fork flag can analogously be retrieved using "
4928 "B<sched_getscheduler>(2) and B<sched_getattr>(2)."
4932 #: build/C/man7/sched.7:442
4934 "The reset-on-fork feature is intended for media-playback applications, and "
4935 "can be used to prevent applications evading the B<RLIMIT_RTTIME> resource "
4936 "limit (see B<getrlimit>(2)) by creating multiple child processes."
4940 #: build/C/man7/sched.7:445
4942 "More precisely, if the reset-on-fork flag is set, the following rules apply "
4943 "for subsequently created children:"
4947 #: build/C/man7/sched.7:453
4949 "If the calling thread has a scheduling policy of B<SCHED_FIFO> or "
4950 "B<SCHED_RR>, the policy is reset to B<SCHED_OTHER> in child processes."
4954 #: build/C/man7/sched.7:456
4956 "If the calling process has a negative nice value, the nice value is reset to "
4957 "zero in child processes."
4961 #: build/C/man7/sched.7:464
4963 "After the reset-on-fork flag has been enabled, it can be reset only if the "
4964 "thread has the B<CAP_SYS_NICE> capability. This flag is disabled in child "
4965 "processes created by B<fork>(2)."
4969 #: build/C/man7/sched.7:464
4971 msgid "Privileges and resource limits"
4975 #: build/C/man7/sched.7:476
4977 "In Linux kernels before 2.6.12, only privileged (B<CAP_SYS_NICE>) threads "
4978 "can set a nonzero static priority (i.e., set a real-time scheduling "
4979 "policy). The only change that an unprivileged thread can make is to set the "
4980 "B<SCHED_OTHER> policy, and this can be done only if the effective user ID of "
4981 "the caller matches the real or effective user ID of the target thread (i.e., "
4982 "the thread specified by I<pid>) whose policy is being changed."
4986 #: build/C/man7/sched.7:482
4988 "A thread must be privileged (B<CAP_SYS_NICE>) in order to set or modify a "
4989 "B<SCHED_DEADLINE> policy."
4993 #: build/C/man7/sched.7:492
4995 "Since Linux 2.6.12, the B<RLIMIT_RTPRIO> resource limit defines a ceiling on "
4996 "an unprivileged thread's static priority for the B<SCHED_RR> and "
4997 "B<SCHED_FIFO> policies. The rules for changing scheduling policy and "
4998 "priority are as follows:"
5002 #: build/C/man7/sched.7:500
5004 "If an unprivileged thread has a nonzero B<RLIMIT_RTPRIO> soft limit, then it "
5005 "can change its scheduling policy and priority, subject to the restriction "
5006 "that the priority cannot be set to a value higher than the maximum of its "
5007 "current priority and its B<RLIMIT_RTPRIO> soft limit."
5011 #: build/C/man7/sched.7:505
5013 "If the B<RLIMIT_RTPRIO> soft limit is 0, then the only permitted changes are "
5014 "to lower the priority, or to switch to a non-real-time policy."
5018 #: build/C/man7/sched.7:510
5020 "Subject to the same rules, another unprivileged thread can also make these "
5021 "changes, as long as the effective user ID of the thread making the change "
5022 "matches the real or effective user ID of the target thread."
5025 #. commit c02aa73b1d18e43cfd79c2f193b225e84ca497c8
5027 #: build/C/man7/sched.7:529
5029 "Special rules apply for the B<SCHED_IDLE> policy. In Linux kernels before "
5030 "2.6.39, an unprivileged thread operating under this policy cannot change its "
5031 "policy, regardless of the value of its B<RLIMIT_RTPRIO> resource limit. In "
5032 "Linux kernels since 2.6.39, an unprivileged thread can switch to either the "
5033 "B<SCHED_BATCH> or the B<SCHED_NORMAL> policy so long as its nice value falls "
5034 "within the range permitted by its B<RLIMIT_NICE> resource limit (see "
5039 #: build/C/man7/sched.7:540
5041 "Privileged (B<CAP_SYS_NICE>) threads ignore the B<RLIMIT_RTPRIO> limit; as "
5042 "with older kernels, they can make arbitrary changes to scheduling policy and "
5043 "priority. See B<getrlimit>(2) for further information on B<RLIMIT_RTPRIO>."
5047 #: build/C/man7/sched.7:540
5049 msgid "Limiting the CPU usage of real-time and deadline processes"
5053 #: build/C/man7/sched.7:553
5055 "A nonblocking infinite loop in a thread scheduled under the B<SCHED_FIFO>, "
5056 "B<SCHED_RR>, or B<SCHED_DEADLINE> policy will block all threads with lower "
5057 "priority forever. Prior to Linux 2.6.25, the only way of preventing a "
5058 "runaway real-time process from freezing the system was to run (at the "
5059 "console) a shell scheduled under a higher static priority than the tested "
5060 "application. This allows an emergency kill of tested real-time applications "
5061 "that do not block or terminate as expected."
5065 #: build/C/man7/sched.7:563
5067 "Since Linux 2.6.25, there are other techniques for dealing with runaway "
5068 "real-time and deadline processes. One of these is to use the "
5069 "B<RLIMIT_RTTIME> resource limit to set a ceiling on the CPU time that a "
5070 "real-time process may consume. See B<getrlimit>(2) for details."
5074 #: build/C/man7/sched.7:571
5076 "Since version 2.6.25, Linux also provides two I</proc> files that can be "
5077 "used to reserve a certain amount of CPU time to be used by non-real-time "
5078 "processes. Reserving some CPU time in this fashion allows some CPU time to "
5079 "be allocated to (say) a root shell that can be used to kill a runaway "
5080 "process. Both of these files specify time values in microseconds:"
5084 #: build/C/man7/sched.7:571
5086 msgid "I</proc/sys/kernel/sched_rt_period_us>"
5090 #: build/C/man7/sched.7:579
5092 "This file specifies a scheduling period that is equivalent to 100% CPU "
5093 "bandwidth. The value in this file can range from 1 to B<INT_MAX>, giving an "
5094 "operating range of 1 microsecond to around 35 minutes. The default value in "
5095 "this file is 1,000,000 (1 second)."
5099 #: build/C/man7/sched.7:579
5101 msgid "I</proc/sys/kernel/sched_rt_runtime_us>"
5105 #: build/C/man7/sched.7:592
5107 "The value in this file specifies how much of the \"period\" time can be used "
5108 "by all real-time and deadline scheduled processes on the system. The value "
5109 "in this file can range from -1 to B<INT_MAX>-1. Specifying -1 makes the "
5110 "runtime the same as the period; that is, no CPU time is set aside for "
5111 "non-real-time processes (which was the Linux behavior before kernel "
5112 "2.6.25). The default value in this file is 950,000 (0.95 seconds), meaning "
5113 "that 5% of the CPU time is reserved for processes that don't run under a "
5114 "real-time or deadline scheduling policy."
5118 #: build/C/man7/sched.7:593
5120 msgid "Response time"
5124 #. .BR request_irq (9).
5126 #: build/C/man7/sched.7:601
5128 "A blocked high priority thread waiting for I/O has a certain response time "
5129 "before it is scheduled again. The device driver writer can greatly reduce "
5130 "this response time by using a \"slow interrupt\" interrupt handler."
5134 #: build/C/man7/sched.7:601
5136 msgid "Miscellaneous"
5140 #: build/C/man7/sched.7:606
5142 "Child processes inherit the scheduling policy and parameters across a "
5143 "B<fork>(2). The scheduling policy and parameters are preserved across "
5148 #: build/C/man7/sched.7:612
5150 "Memory locking is usually needed for real-time processes to avoid paging "
5151 "delays; this can be done with B<mlock>(2) or B<mlockall>(2)."
5155 #: build/C/man7/sched.7:623
5157 "Originally, Standard Linux was intended as a general-purpose operating "
5158 "system being able to handle background processes, interactive applications, "
5159 "and less demanding real-time applications (applications that need to usually "
5160 "meet timing deadlines). Although the Linux kernel 2.6 allowed for kernel "
5161 "preemption and the newly introduced O(1) scheduler ensures that the time "
5162 "needed to schedule is fixed and deterministic irrespective of the number of "
5163 "active tasks, true real-time computing was not possible up to kernel version "
5168 #: build/C/man7/sched.7:623
5170 msgid "Real-time features in the mainline Linux kernel"
5173 #. FIXME . Probably this text will need some minor tweaking
5174 #. by about the time of 2.6.30; ask Carsten Emde about this then.
5176 #: build/C/man7/sched.7:637
5178 "From kernel version 2.6.18 onward, however, Linux is gradually becoming "
5179 "equipped with real-time capabilities, most of which are derived from the "
5180 "former I<realtime-preempt> patches developed by Ingo Molnar, Thomas "
5181 "Gleixner, Steven Rostedt, and others. Until the patches have been "
5182 "completely merged into the mainline kernel (this is expected to be around "
5183 "kernel version 2.6.30), they must be installed to achieve the best real-time "
5184 "performance. These patches are named:"
5188 #: build/C/man7/sched.7:641
5190 msgid "patch-I<kernelversion>-rtI<patchversion>\n"
5194 #: build/C/man7/sched.7:647
5196 "and can be downloaded from E<.UR "
5197 "http://www.kernel.org\\:/pub\\:/linux\\:/kernel\\:/projects\\:/rt/> E<.UE .>"
5201 #: build/C/man7/sched.7:656
5203 "Without the patches and prior to their full inclusion into the mainline "
5204 "kernel, the kernel configuration offers only the three preemption classes "
5205 "B<CONFIG_PREEMPT_NONE>, B<CONFIG_PREEMPT_VOLUNTARY>, and "
5206 "B<CONFIG_PREEMPT_DESKTOP> which respectively provide no, some, and "
5207 "considerable reduction of the worst-case scheduling latency."
5211 #: build/C/man7/sched.7:665
5213 "With the patches applied or after their full inclusion into the mainline "
5214 "kernel, the additional configuration item B<CONFIG_PREEMPT_RT> becomes "
5215 "available. If this is selected, Linux is transformed into a regular "
5216 "real-time operating system. The FIFO and RR scheduling policies are then "
5217 "used to run a thread with true real-time priority and a minimum worst-case "
5218 "scheduling latency."
5222 #: build/C/man7/sched.7:691
5224 "B<chrt>(1), B<getpriority>(2), B<mlock>(2), B<mlockall>(2), B<munlock>(2), "
5225 "B<munlockall>(2), B<nice>(2), B<sched_get_priority_max>(2), "
5226 "B<sched_get_priority_min>(2), B<sched_getscheduler>(2), "
5227 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_rr_get_interval>(2), "
5228 "B<sched_setaffinity>(2), B<sched_setscheduler>(2), B<sched_setparam>(2), "
5229 "B<sched_yield>(2), B<setpriority>(2), B<pthread_getaffinity_np>(3), "
5230 "B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), B<capabilities>(7), "
5235 #: build/C/man7/sched.7:695
5237 "I<Programming for the real world - POSIX.4> by Bill O. Gallmeister, O'Reilly "
5238 "& Associates, Inc., ISBN 1-56592-074-0."
5242 #: build/C/man7/sched.7:702
5244 "The Linux kernel source files I<Documentation/scheduler/sched-deadline.txt>, "
5245 "I<Documentation/scheduler/sched-rt-group.txt>, "
5246 "I<Documentation/scheduler/sched-design-CFS.txt>, and "
5247 "I<Documentation/scheduler/sched-nice-design.txt>"