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: 2013-08-15 19:32+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=CHARSET\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_setparam.2:30 build/C/man2/sched_setscheduler.2:46 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20
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_setparam.2:30 build/C/man2/sched_setscheduler.2:46 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20
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_setparam.2:31 build/C/man2/sched_setscheduler.2:47 build/C/man2/sched_yield.2:30 build/C/man2/setns.2:9 build/C/man2/unshare.2:21
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_setparam.2:33 build/C/man2/sched_setscheduler.2:50 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_setparam.2:47 build/C/man2/sched_setscheduler.2:66 build/C/man2/sched_yield.2:36 build/C/man2/setns.2:18 build/C/man2/unshare.2:50
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 bitset. 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:874 build/C/man2/kcmp.2:124 build/C/man2/sched_get_priority_max.2:98 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_setparam.2:87 build/C/man2/sched_setscheduler.2:422 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:991 build/C/man2/kcmp.2:195 build/C/man3/sched_getcpu.3:70 build/C/man2/sched_setaffinity.2:148 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:998 build/C/man2/kcmp.2:199 build/C/man2/sched_get_priority_max.2:114 build/C/man3/sched_getcpu.3:72 build/C/man2/sched_rr_get_interval.2:94 build/C/man2/sched_setaffinity.2:159 build/C/man2/sched_setparam.2:110 build/C/man2/sched_setscheduler.2:444 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:1002 build/C/man2/kcmp.2:202 build/C/man3/sched_getcpu.3:75 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setaffinity.2:161 build/C/man2/sched_setparam.2:112 build/C/man2/sched_setscheduler.2:447 build/C/man2/sched_yield.2:54 build/C/man2/setns.2:106 build/C/man2/unshare.2:232
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 bitsets 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 bitset), 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:1027 build/C/man2/sched_setscheduler.2:530
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:1069 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:1167 build/C/man2/kcmp.2:219 build/C/man2/sched_get_priority_max.2:116 build/C/man3/sched_getcpu.3:95 build/C/man2/sched_rr_get_interval.2:132 build/C/man2/sched_setaffinity.2:214 build/C/man2/sched_setparam.2:118 build/C/man2/sched_setscheduler.2:538 build/C/man2/sched_yield.2:79 build/C/man2/setns.2:199 build/C/man2/unshare.2:266
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:1181 build/C/man2/kcmp.2:222 build/C/man2/sched_get_priority_max.2:128 build/C/man3/sched_getcpu.3:97 build/C/man2/sched_rr_get_interval.2:138 build/C/man2/sched_setaffinity.2:233 build/C/man2/sched_setparam.2:134 build/C/man2/sched_setscheduler.2:566 build/C/man2/sched_yield.2:85 build/C/man2/setns.2:205 build/C/man2/unshare.2:275
637 #: build/C/man3/CPU_SET.3:368 build/C/man2/clone.2:1188 build/C/man2/kcmp.2:229 build/C/man2/sched_get_priority_max.2:135 build/C/man3/sched_getcpu.3:104 build/C/man2/sched_rr_get_interval.2:145 build/C/man2/sched_setaffinity.2:240 build/C/man2/sched_setparam.2:141 build/C/man2/sched_setscheduler.2:573 build/C/man2/sched_yield.2:92 build/C/man2/setns.2:212 build/C/man2/unshare.2:282
639 "This page is part of release 3.53 of the Linux I<man-pages> project. A "
640 "description of the project, and information about reporting bugs, can be "
641 "found at \\%http://www.kernel.org/doc/man-pages/."
645 #: build/C/man2/clone.2:45
651 #: build/C/man2/clone.2:45
657 #: build/C/man2/clone.2:48
658 msgid "clone, __clone2 - create a child process"
662 #: build/C/man2/clone.2:51
664 msgid "/* Prototype for the glibc wrapper function */\n"
668 #: build/C/man2/clone.2:53 build/C/man3/sched_getcpu.3:32 build/C/man2/sched_setparam.2:36 build/C/man2/sched_setscheduler.2:53 build/C/man2/unshare.2:26
670 msgid "B<#include E<lt>sched.hE<gt>>\n"
674 #: build/C/man2/clone.2:58
677 "B<int clone(int (*>I<fn>B<)(void *), void *>I<child_stack>B<,>\n"
678 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
679 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
680 "*>I<ctid>B< */ );>\n"
684 #: build/C/man2/clone.2:60
686 msgid "/* Prototype for the raw system call */\n"
690 #: build/C/man2/clone.2:64
693 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
694 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
695 "B< struct pt_regs *>I<regs>B<);>\n"
699 #: build/C/man2/clone.2:69
701 "Feature Test Macro Requirements for glibc wrapper function (see "
702 "B<feature_test_macros>(7)):"
706 #: build/C/man2/clone.2:72
711 #: build/C/man2/clone.2:75 build/C/man3/sched_getcpu.3:45 build/C/man2/unshare.2:39
713 msgid "Since glibc 2.14:"
717 #: build/C/man2/clone.2:78 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
721 #. FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
723 #: build/C/man2/clone.2:78 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
725 msgid "Before glibc 2.14:"
729 #: build/C/man2/clone.2:83 build/C/man3/sched_getcpu.3:52 build/C/man2/unshare.2:47
732 "_BSD_SOURCE || _SVID_SOURCE\n"
733 " /* _GNU_SOURCE also suffices */\n"
737 #: build/C/man2/clone.2:90
738 msgid "B<clone>() creates a new process, in a manner similar to B<fork>(2)."
742 #: build/C/man2/clone.2:97
744 "This page describes both the glibc B<clone>() wrapper function and the "
745 "underlying system call on which it is based. The main text describes the "
746 "wrapper function; the differences for the raw system call are described "
747 "toward the end of this page."
751 #: build/C/man2/clone.2:109
753 "Unlike B<fork>(2), B<clone>() allows the child process to share parts of "
754 "its execution context with the calling process, such as the memory space, "
755 "the table of file descriptors, and the table of signal handlers. (Note that "
756 "on this manual page, \"calling process\" normally corresponds to \"parent "
757 "process\". But see the description of B<CLONE_PARENT> below.)"
761 #: build/C/man2/clone.2:114
763 "The main use of B<clone>() is to implement threads: multiple threads of "
764 "control in a program that run concurrently in a shared memory space."
768 #: build/C/man2/clone.2:134
770 "When the child process is created with B<clone>(), it executes the function "
771 "I<fn>(I<arg>). (This differs from B<fork>(2), where execution continues in "
772 "the child from the point of the B<fork>(2) call.) The I<fn> argument is a "
773 "pointer to a function that is called by the child process at the beginning "
774 "of its execution. The I<arg> argument is passed to the I<fn> function."
778 #: build/C/man2/clone.2:144
780 "When the I<fn>(I<arg>) function application returns, the child process "
781 "terminates. The integer returned by I<fn> is the exit code for the child "
782 "process. The child process may also terminate explicitly by calling "
783 "B<exit>(2) or after receiving a fatal signal."
787 #: build/C/man2/clone.2:160
789 "The I<child_stack> argument specifies the location of the stack used by the "
790 "child process. Since the child and calling process may share memory, it is "
791 "not possible for the child process to execute in the same stack as the "
792 "calling process. The calling process must therefore set up memory space for "
793 "the child stack and pass a pointer to this space to B<clone>(). Stacks grow "
794 "downward on all processors that run Linux (except the HP PA processors), so "
795 "I<child_stack> usually points to the topmost address of the memory space set "
796 "up for the child stack."
800 #: build/C/man2/clone.2:176
802 "The low byte of I<flags> contains the number of the I<termination signal> "
803 "sent to the parent when the child dies. If this signal is specified as "
804 "anything other than B<SIGCHLD>, then the parent process must specify the "
805 "B<__WALL> or B<__WCLONE> options when waiting for the child with "
806 "B<wait>(2). If no signal is specified, then the parent process is not "
807 "signaled when the child terminates."
811 #: build/C/man2/clone.2:181
813 "I<flags> may also be bitwise-or'ed with zero or more of the following "
814 "constants, in order to specify what is shared between the calling process "
815 "and the child process:"
819 #: build/C/man2/clone.2:181
821 msgid "B<CLONE_CHILD_CLEARTID> (since Linux 2.5.49)"
825 #: build/C/man2/clone.2:191
827 "Erase child thread ID at location I<ctid> in child memory when the child "
828 "exits, and do a wakeup on the futex at that address. The address involved "
829 "may be changed by the B<set_tid_address>(2) system call. This is used by "
830 "threading libraries."
834 #: build/C/man2/clone.2:191
836 msgid "B<CLONE_CHILD_SETTID> (since Linux 2.5.49)"
840 #: build/C/man2/clone.2:196
841 msgid "Store child thread ID at location I<ctid> in child memory."
845 #: build/C/man2/clone.2:196
847 msgid "B<CLONE_FILES> (since Linux 2.0)"
851 #: build/C/man2/clone.2:209
853 "If B<CLONE_FILES> is set, the calling process and the child process share "
854 "the same file descriptor table. Any file descriptor created by the calling "
855 "process or by the child process is also valid in the other process. "
856 "Similarly, if one of the processes closes a file descriptor, or changes its "
857 "associated flags (using the B<fcntl>(2) B<F_SETFD> operation), the other "
858 "process is also affected."
862 #: build/C/man2/clone.2:223
864 "If B<CLONE_FILES> is not set, the child process inherits a copy of all file "
865 "descriptors opened in the calling process at the time of B<clone>(). (The "
866 "duplicated file descriptors in the child refer to the same open file "
867 "descriptions (see B<open>(2)) as the corresponding file descriptors in the "
868 "calling process.) Subsequent operations that open or close file "
869 "descriptors, or change file descriptor flags, performed by either the "
870 "calling process or the child process do not affect the other process."
874 #: build/C/man2/clone.2:223
876 msgid "B<CLONE_FS> (since Linux 2.0)"
880 #: build/C/man2/clone.2:238
882 "If B<CLONE_FS> is set, the caller and the child process share the same file "
883 "system information. This includes the root of the file system, the current "
884 "working directory, and the umask. Any call to B<chroot>(2), B<chdir>(2), or "
885 "B<umask>(2) performed by the calling process or the child process also "
886 "affects the other process."
890 #: build/C/man2/clone.2:250
892 "If B<CLONE_FS> is not set, the child process works on a copy of the file "
893 "system information of the calling process at the time of the B<clone>() "
894 "call. Calls to B<chroot>(2), B<chdir>(2), B<umask>(2) performed later by "
895 "one of the processes do not affect the other process."
899 #: build/C/man2/clone.2:250
901 msgid "B<CLONE_IO> (since Linux 2.6.25)"
905 #: build/C/man2/clone.2:259
907 "If B<CLONE_IO> is set, then the new process shares an I/O context with the "
908 "calling process. If this flag is not set, then (as with B<fork>(2)) the "
909 "new process has its own I/O context."
912 #. The following based on text from Jens Axboe
913 #. the anticipatory and CFQ scheduler
916 #: build/C/man2/clone.2:276
918 "The I/O context is the I/O scope of the disk scheduler (i.e, what the I/O "
919 "scheduler uses to model scheduling of a process's I/O). If processes share "
920 "the same I/O context, they are treated as one by the I/O scheduler. As a "
921 "consequence, they get to share disk time. For some I/O schedulers, if two "
922 "processes share an I/O context, they will be allowed to interleave their "
923 "disk access. If several threads are doing I/O on behalf of the same process "
924 "(B<aio_read>(3), for instance), they should employ B<CLONE_IO> to get better "
929 #: build/C/man2/clone.2:280
931 "If the kernel is not configured with the B<CONFIG_BLOCK> option, this flag "
936 #: build/C/man2/clone.2:280 build/C/man2/unshare.2:96
938 msgid "B<CLONE_NEWIPC> (since Linux 2.6.19)"
942 #: build/C/man2/clone.2:290
944 "If B<CLONE_NEWIPC> is set, then create the process in a new IPC namespace. "
945 "If this flag is not set, then (as with B<fork>(2)), the process is created "
946 "in the same IPC namespace as the calling process. This flag is intended for "
947 "the implementation of containers."
950 #. commit 7eafd7c74c3f2e67c27621b987b28397110d643f
951 #. https://lwn.net/Articles/312232/
953 #: build/C/man2/clone.2:302
955 "An IPC namespace provides an isolated view of System V IPC objects (see "
956 "B<svipc>(7)) and (since Linux 2.6.30) POSIX message queues (see "
957 "B<mq_overview>(7)). The common characteristic of these IPC mechanisms is "
958 "that IPC objects are identified by mechanisms other than filesystem "
963 #: build/C/man2/clone.2:306
965 "Objects created in an IPC namespace are visible to all other processes that "
966 "are members of that namespace, but are not visible to processes in other IPC "
971 #: build/C/man2/clone.2:310
973 "When an IPC namespace is destroyed (i.e., when the last process that is a "
974 "member of the namespace terminates), all IPC objects in the namespace are "
975 "automatically destroyed."
979 #: build/C/man2/clone.2:319
981 "Use of this flag requires: a kernel configured with the B<CONFIG_SYSVIPC> "
982 "and B<CONFIG_IPC_NS> options and that the process be privileged "
983 "(B<CAP_SYS_ADMIN>). This flag can't be specified in conjunction with "
988 #: build/C/man2/clone.2:319 build/C/man2/unshare.2:113
990 msgid "B<CLONE_NEWNET> (since Linux 2.6.24)"
993 #. FIXME Check when the implementation was completed
995 #: build/C/man2/clone.2:324
997 "(The implementation of this flag was completed only by about kernel version "
1002 #: build/C/man2/clone.2:333
1004 "If B<CLONE_NEWNET> is set, then create the process in a new network "
1005 "namespace. If this flag is not set, then (as with B<fork>(2)), the process "
1006 "is created in the same network namespace as the calling process. This flag "
1007 "is intended for the implementation of containers."
1010 #. FIXME Add pointer to veth(4) page when it is eventually completed
1012 #: build/C/man2/clone.2:348
1014 "A network namespace provides an isolated view of the networking stack "
1015 "(network device interfaces, IPv4 and IPv6 protocol stacks, IP routing "
1016 "tables, firewall rules, the I</proc/net> and I</sys/class/net> directory "
1017 "trees, sockets, etc.). A physical network device can live in exactly one "
1018 "network namespace. A virtual network device (\"veth\") pair provides a "
1019 "pipe-like abstraction that can be used to create tunnels between network "
1020 "namespaces, and can be used to create a bridge to a physical network device "
1021 "in another namespace."
1025 #: build/C/man2/clone.2:353
1027 "When a network namespace is freed (i.e., when the last process in the "
1028 "namespace terminates), its physical network devices are moved back to the "
1029 "initial network namespace (not to the parent of the process)."
1033 #: build/C/man2/clone.2:358
1035 "Use of this flag requires: a kernel configured with the B<CONFIG_NET_NS> "
1036 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
1040 #: build/C/man2/clone.2:358
1042 msgid "B<CLONE_NEWNS> (since Linux 2.4.19)"
1046 #: build/C/man2/clone.2:361
1047 msgid "Start the child in a new mount namespace."
1051 #: build/C/man2/clone.2:382
1053 "Every process lives in a mount namespace. The I<namespace> of a process is "
1054 "the data (the set of mounts) describing the file hierarchy as seen by that "
1055 "process. After a B<fork>(2) or B<clone>() where the B<CLONE_NEWNS> flag "
1056 "is not set, the child lives in the same mount namespace as the parent. The "
1057 "system calls B<mount>(2) and B<umount>(2) change the mount namespace of "
1058 "the calling process, and hence affect all processes that live in the same "
1059 "namespace, but do not affect processes in a different mount namespace."
1063 #: build/C/man2/clone.2:389
1065 "After a B<clone>() where the B<CLONE_NEWNS> flag is set, the cloned child "
1066 "is started in a new mount namespace, initialized with a copy of the "
1067 "namespace of the parent."
1071 #: build/C/man2/clone.2:401
1073 "Only a privileged process (one having the B<CAP_SYS_ADMIN> capability) may "
1074 "specify the B<CLONE_NEWNS> flag. It is not permitted to specify both "
1075 "B<CLONE_NEWNS> and B<CLONE_FS> in the same B<clone>() call."
1079 #: build/C/man2/clone.2:401
1081 msgid "B<CLONE_NEWPID> (since Linux 2.6.24)"
1084 #. This explanation draws a lot of details from
1085 #. http://lwn.net/Articles/259217/
1086 #. Authors: Pavel Emelyanov <xemul@openvz.org>
1087 #. and Kir Kolyshkin <kir@openvz.org>
1089 #. The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
1090 #. Author: Pavel Emelyanov <xemul@openvz.org>
1092 #: build/C/man2/clone.2:418
1094 "If B<CLONE_NEWPID> is set, then create the process in a new PID namespace. "
1095 "If this flag is not set, then (as with B<fork>(2)), the process is created "
1096 "in the same PID namespace as the calling process. This flag is intended for "
1097 "the implementation of containers."
1101 #: build/C/man2/clone.2:427
1103 "A PID namespace provides an isolated environment for PIDs: PIDs in a new "
1104 "namespace start at 1, somewhat like a standalone system, and calls to "
1105 "B<fork>(2), B<vfork>(2), or B<clone>() will produce processes with PIDs "
1106 "that are unique within the namespace."
1110 #: build/C/man2/clone.2:439
1112 "The first process created in a new namespace (i.e., the process created "
1113 "using the B<CLONE_NEWPID> flag) has the PID 1, and is the \"init\" process "
1114 "for the namespace. Children that are orphaned within the namespace will be "
1115 "reparented to this process rather than B<init>(8). Unlike the traditional "
1116 "B<init> process, the \"init\" process of a PID namespace can terminate, and "
1117 "if it does, all of the processes in the namespace are terminated."
1121 #: build/C/man2/clone.2:458
1123 "PID namespaces form a hierarchy. When a new PID namespace is created, the "
1124 "processes in that namespace are visible in the PID namespace of the process "
1125 "that created the new namespace; analogously, if the parent PID namespace is "
1126 "itself the child of another PID namespace, then processes in the child and "
1127 "parent PID namespaces will both be visible in the grandparent PID "
1128 "namespace. Conversely, the processes in the \"child\" PID namespace do not "
1129 "see the processes in the parent namespace. The existence of a namespace "
1130 "hierarchy means that each process may now have multiple PIDs: one for each "
1131 "namespace in which it is visible; each of these PIDs is unique within the "
1132 "corresponding namespace. (A call to B<getpid>(2) always returns the PID "
1133 "associated with the namespace in which the process lives.)"
1136 #. mount -t proc proc /proc
1138 #: build/C/man2/clone.2:474
1140 "After creating the new namespace, it is useful for the child to change its "
1141 "root directory and mount a new procfs instance at I</proc> so that tools "
1142 "such as B<ps>(1) work correctly. (If B<CLONE_NEWNS> is also included in "
1143 "I<flags>, then it isn't necessary to change the root directory: a new procfs "
1144 "instance can be mounted directly over I</proc>.)"
1148 #: build/C/man2/clone.2:481
1150 "Use of this flag requires: a kernel configured with the B<CONFIG_PID_NS> "
1151 "option and that the process be privileged (B<CAP_SYS_ADMIN>). This flag "
1152 "can't be specified in conjunction with B<CLONE_THREAD>."
1156 #: build/C/man2/clone.2:481 build/C/man2/unshare.2:149
1158 msgid "B<CLONE_NEWUTS> (since Linux 2.6.19)"
1162 #: build/C/man2/clone.2:493
1164 "If B<CLONE_NEWUTS> is set, then create the process in a new UTS namespace, "
1165 "whose identifiers are initialized by duplicating the identifiers from the "
1166 "UTS namespace of the calling process. If this flag is not set, then (as "
1167 "with B<fork>(2)), the process is created in the same UTS namespace as the "
1168 "calling process. This flag is intended for the implementation of "
1173 #: build/C/man2/clone.2:505
1175 "A UTS namespace is the set of identifiers returned by B<uname>(2); among "
1176 "these, the domain name and the host name can be modified by "
1177 "B<setdomainname>(2) and B<sethostname>(2), respectively. Changes made to "
1178 "the identifiers in a UTS namespace are visible to all other processes in the "
1179 "same namespace, but are not visible to processes in other UTS namespaces."
1183 #: build/C/man2/clone.2:510
1185 "Use of this flag requires: a kernel configured with the B<CONFIG_UTS_NS> "
1186 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
1190 #: build/C/man2/clone.2:510
1192 msgid "B<CLONE_PARENT> (since Linux 2.3.12)"
1196 #: build/C/man2/clone.2:517
1198 "If B<CLONE_PARENT> is set, then the parent of the new child (as returned by "
1199 "B<getppid>(2)) will be the same as that of the calling process."
1203 #: build/C/man2/clone.2:523
1205 "If B<CLONE_PARENT> is not set, then (as with B<fork>(2)) the child's parent "
1206 "is the calling process."
1210 #: build/C/man2/clone.2:531
1212 "Note that it is the parent process, as returned by B<getppid>(2), which is "
1213 "signaled when the child terminates, so that if B<CLONE_PARENT> is set, then "
1214 "the parent of the calling process, rather than the calling process itself, "
1219 #: build/C/man2/clone.2:531
1221 msgid "B<CLONE_PARENT_SETTID> (since Linux 2.5.49)"
1225 #: build/C/man2/clone.2:539
1227 "Store child thread ID at location I<ptid> in parent and child memory. (In "
1228 "Linux 2.5.32-2.5.48 there was a flag B<CLONE_SETTID> that did this.)"
1232 #: build/C/man2/clone.2:539
1234 msgid "B<CLONE_PID> (obsolete)"
1238 #: build/C/man2/clone.2:550
1240 "If B<CLONE_PID> is set, the child process is created with the same process "
1241 "ID as the calling process. This is good for hacking the system, but "
1242 "otherwise of not much use. Since 2.3.21 this flag can be specified only by "
1243 "the system boot process (PID 0). It disappeared in Linux 2.5.16."
1247 #: build/C/man2/clone.2:550
1249 msgid "B<CLONE_PTRACE> (since Linux 2.2)"
1253 #: build/C/man2/clone.2:557
1255 "If B<CLONE_PTRACE> is specified, and the calling process is being traced, "
1256 "then trace the child also (see B<ptrace>(2))."
1260 #: build/C/man2/clone.2:557
1262 msgid "B<CLONE_SETTLS> (since Linux 2.5.32)"
1266 #: build/C/man2/clone.2:564
1268 "The I<newtls> argument is the new TLS (Thread Local Storage) descriptor. "
1269 "(See B<set_thread_area>(2).)"
1273 #: build/C/man2/clone.2:564
1275 msgid "B<CLONE_SIGHAND> (since Linux 2.0)"
1279 #: build/C/man2/clone.2:580
1281 "If B<CLONE_SIGHAND> is set, the calling process and the child process share "
1282 "the same table of signal handlers. If the calling process or child process "
1283 "calls B<sigaction>(2) to change the behavior associated with a signal, the "
1284 "behavior is changed in the other process as well. However, the calling "
1285 "process and child processes still have distinct signal masks and sets of "
1286 "pending signals. So, one of them may block or unblock some signals using "
1287 "B<sigprocmask>(2) without affecting the other process."
1291 #: build/C/man2/clone.2:591
1293 "If B<CLONE_SIGHAND> is not set, the child process inherits a copy of the "
1294 "signal handlers of the calling process at the time B<clone>() is called. "
1295 "Calls to B<sigaction>(2) performed later by one of the processes have no "
1296 "effect on the other process."
1300 #: build/C/man2/clone.2:599
1302 "Since Linux 2.6.0-test6, I<flags> must also include B<CLONE_VM> if "
1303 "B<CLONE_SIGHAND> is specified"
1307 #: build/C/man2/clone.2:599
1309 msgid "B<CLONE_STOPPED> (since Linux 2.6.0-test2)"
1313 #: build/C/man2/clone.2:608
1315 "If B<CLONE_STOPPED> is set, then the child is initially stopped (as though "
1316 "it was sent a B<SIGSTOP> signal), and must be resumed by sending it a "
1317 "B<SIGCONT> signal."
1320 #. glibc 2.8 removed this defn from bits/sched.h
1322 #: build/C/man2/clone.2:616
1324 "This flag was I<deprecated> from Linux 2.6.25 onward, and was I<removed> "
1325 "altogether in Linux 2.6.38."
1329 #: build/C/man2/clone.2:616
1331 msgid "B<CLONE_SYSVSEM> (since Linux 2.5.10)"
1335 #: build/C/man2/clone.2:625
1337 "If B<CLONE_SYSVSEM> is set, then the child and the calling process share a "
1338 "single list of System V semaphore undo values (see B<semop>(2)). If this "
1339 "flag is not set, then the child has a separate undo list, which is initially "
1344 #: build/C/man2/clone.2:625
1346 msgid "B<CLONE_THREAD> (since Linux 2.4.0-test8)"
1350 #: build/C/man2/clone.2:634
1352 "If B<CLONE_THREAD> is set, the child is placed in the same thread group as "
1353 "the calling process. To make the remainder of the discussion of "
1354 "B<CLONE_THREAD> more readable, the term \"thread\" is used to refer to the "
1355 "processes within a thread group."
1359 #: build/C/man2/clone.2:642
1361 "Thread groups were a feature added in Linux 2.4 to support the POSIX threads "
1362 "notion of a set of threads that share a single PID. Internally, this shared "
1363 "PID is the so-called thread group identifier (TGID) for the thread group. "
1364 "Since Linux 2.4, calls to B<getpid>(2) return the TGID of the caller."
1368 #: build/C/man2/clone.2:651
1370 "The threads within a group can be distinguished by their (system-wide) "
1371 "unique thread IDs (TID). A new thread's TID is available as the function "
1372 "result returned to the caller of B<clone>(), and a thread can obtain its own "
1373 "TID using B<gettid>(2)."
1377 #: build/C/man2/clone.2:661
1379 "When a call is made to B<clone>() without specifying B<CLONE_THREAD>, then "
1380 "the resulting thread is placed in a new thread group whose TGID is the same "
1381 "as the thread's TID. This thread is the I<leader> of the new thread group."
1385 #: build/C/man2/clone.2:683
1387 "A new thread created with B<CLONE_THREAD> has the same parent process as the "
1388 "caller of B<clone>() (i.e., like B<CLONE_PARENT>), so that calls to "
1389 "B<getppid>(2) return the same value for all of the threads in a thread "
1390 "group. When a B<CLONE_THREAD> thread terminates, the thread that created it "
1391 "using B<clone>() is not sent a B<SIGCHLD> (or other termination) signal; "
1392 "nor can the status of such a thread be obtained using B<wait>(2). (The "
1393 "thread is said to be I<detached>.)"
1397 #: build/C/man2/clone.2:688
1399 "After all of the threads in a thread group terminate the parent process of "
1400 "the thread group is sent a B<SIGCHLD> (or other termination) signal."
1404 #: build/C/man2/clone.2:693
1406 "If any of the threads in a thread group performs an B<execve>(2), then all "
1407 "threads other than the thread group leader are terminated, and the new "
1408 "program is executed in the thread group leader."
1412 #: build/C/man2/clone.2:699
1414 "If one of the threads in a thread group creates a child using B<fork>(2), "
1415 "then any thread in the group can B<wait>(2) for that child."
1419 #: build/C/man2/clone.2:707
1421 "Since Linux 2.5.35, I<flags> must also include B<CLONE_SIGHAND> if "
1422 "B<CLONE_THREAD> is specified."
1426 #: build/C/man2/clone.2:712
1428 "Signals may be sent to a thread group as a whole (i.e., a TGID) using "
1429 "B<kill>(2), or to a specific thread (i.e., TID) using B<tgkill>(2)."
1433 #: build/C/man2/clone.2:717
1435 "Signal dispositions and actions are process-wide: if an unhandled signal is "
1436 "delivered to a thread, then it will affect (terminate, stop, continue, be "
1437 "ignored in) all members of the thread group."
1441 #: build/C/man2/clone.2:730
1443 "Each thread has its own signal mask, as set by B<sigprocmask>(2), but "
1444 "signals can be pending either: for the whole process (i.e., deliverable to "
1445 "any member of the thread group), when sent with B<kill>(2); or for an "
1446 "individual thread, when sent with B<tgkill>(2). A call to B<sigpending>(2) "
1447 "returns a signal set that is the union of the signals pending for the whole "
1448 "process and the signals that are pending for the calling thread."
1452 #: build/C/man2/clone.2:742
1454 "If B<kill>(2) is used to send a signal to a thread group, and the thread "
1455 "group has installed a handler for the signal, then the handler will be "
1456 "invoked in exactly one, arbitrarily selected member of the thread group that "
1457 "has not blocked the signal. If multiple threads in a group are waiting to "
1458 "accept the same signal using B<sigwaitinfo>(2), the kernel will arbitrarily "
1459 "select one of these threads to receive a signal sent using B<kill>(2)."
1463 #: build/C/man2/clone.2:742
1465 msgid "B<CLONE_UNTRACED> (since Linux 2.5.46)"
1469 #: build/C/man2/clone.2:749
1471 "If B<CLONE_UNTRACED> is specified, then a tracing process cannot force "
1472 "B<CLONE_PTRACE> on this child process."
1476 #: build/C/man2/clone.2:749
1478 msgid "B<CLONE_VFORK> (since Linux 2.2)"
1482 #: build/C/man2/clone.2:761
1484 "If B<CLONE_VFORK> is set, the execution of the calling process is suspended "
1485 "until the child releases its virtual memory resources via a call to "
1486 "B<execve>(2) or B<_exit>(2) (as with B<vfork>(2))."
1490 #: build/C/man2/clone.2:767
1492 "If B<CLONE_VFORK> is not set then both the calling process and the child are "
1493 "schedulable after the call, and an application should not rely on execution "
1494 "occurring in any particular order."
1498 #: build/C/man2/clone.2:767
1500 msgid "B<CLONE_VM> (since Linux 2.0)"
1504 #: build/C/man2/clone.2:780
1506 "If B<CLONE_VM> is set, the calling process and the child process run in the "
1507 "same memory space. In particular, memory writes performed by the calling "
1508 "process or by the child process are also visible in the other process. "
1509 "Moreover, any memory mapping or unmapping performed with B<mmap>(2) or "
1510 "B<munmap>(2) by the child or calling process also affects the other "
1515 #: build/C/man2/clone.2:789
1517 "If B<CLONE_VM> is not set, the child process runs in a separate copy of the "
1518 "memory space of the calling process at the time of B<clone>(). Memory "
1519 "writes or file mappings/unmappings performed by one of the processes do not "
1520 "affect the other, as with B<fork>(2)."
1524 #: build/C/man2/clone.2:789
1526 msgid "The raw system call interface"
1530 #: build/C/man2/clone.2:805
1532 "The raw B<clone>() system call corresponds more closely to B<fork>(2) in "
1533 "that execution in the child continues from the point of the call. As such, "
1534 "the I<fn> and I<arg> arguments of the B<clone>() wrapper function are "
1535 "omitted. Furthermore, the argument order changes. The raw system call "
1536 "interface on x86 and many other architectures is roughly:"
1540 #: build/C/man2/clone.2:811
1543 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
1544 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
1545 "B< struct pt_regs *>I<regs>B<);>\n"
1549 #: build/C/man2/clone.2:822
1551 "Another difference for the raw system call is that the I<child_stack> "
1552 "argument may be zero, in which case copy-on-write semantics ensure that the "
1553 "child gets separate copies of stack pages when either process modifies the "
1554 "stack. In this case, for correct operation, the B<CLONE_VM> option should "
1559 #: build/C/man2/clone.2:830
1561 "For some architectures, the order of the arguments for the system call "
1562 "differs from that shown above. On the score, microblaze, ARM, ARM 64, "
1563 "PA-RISC, arc, Power PC, xtensa, and MIPS architectures, the order of the "
1564 "fourth and fifth arguments is reversed. On the cris and s390 architectures, "
1565 "the order of the first and second arguments is reversed."
1569 #: build/C/man2/clone.2:830
1571 msgid "blackfin, m68k, and sparc"
1575 #: build/C/man2/clone.2:834
1577 "The argument-passing conventions on blackfin, m68k, and sparc are different "
1578 "from descriptions above. For details, see the kernel (and glibc) source."
1582 #: build/C/man2/clone.2:834
1588 #: build/C/man2/clone.2:836
1589 msgid "On ia64, a different interface is used:"
1593 #: build/C/man2/clone.2:843
1596 "B<int __clone2(int (*>I<fn>B<)(void *), >\n"
1597 "B< void *>I<child_stack_base>B<, size_t >I<stack_size>B<,>\n"
1598 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
1599 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
1600 "*>I<ctid>B< */ );>\n"
1604 #: build/C/man2/clone.2:855
1606 "The prototype shown above is for the glibc wrapper function; the raw system "
1607 "call interface has no I<fn> or I<arg> argument, and changes the order of the "
1608 "arguments so that I<flags> is the first argument, and I<tls> is the last "
1613 #: build/C/man2/clone.2:866
1615 "B<__clone2>() operates in the same way as B<clone>(), except that "
1616 "I<child_stack_base> points to the lowest address of the child's stack area, "
1617 "and I<stack_size> specifies the size of the stack pointed to by "
1618 "I<child_stack_base>."
1622 #: build/C/man2/clone.2:866
1624 msgid "Linux 2.4 and earlier"
1628 #: build/C/man2/clone.2:874
1630 "In Linux 2.4 and earlier, B<clone>() does not take arguments I<ptid>, "
1631 "I<tls>, and I<ctid>."
1634 #. gettid(2) returns current->pid;
1635 #. getpid(2) returns current->tgid;
1637 #: build/C/man2/clone.2:883
1639 "On success, the thread ID of the child process is returned in the caller's "
1640 "thread of execution. On failure, -1 is returned in the caller's context, no "
1641 "child process will be created, and I<errno> will be set appropriately."
1645 #: build/C/man2/clone.2:883 build/C/man2/kcmp.2:167 build/C/man2/sched_get_priority_max.2:108 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_setparam.2:96 build/C/man2/sched_setscheduler.2:432 build/C/man2/sched_yield.2:48 build/C/man2/setns.2:77 build/C/man2/unshare.2:212
1651 #: build/C/man2/clone.2:884
1657 #: build/C/man2/clone.2:887
1658 msgid "Too many processes are already running."
1662 #: build/C/man2/clone.2:887 build/C/man2/clone.2:894 build/C/man2/clone.2:909 build/C/man2/clone.2:917 build/C/man2/clone.2:925 build/C/man2/clone.2:933 build/C/man2/clone.2:939 build/C/man2/clone.2:949 build/C/man2/clone.2:957 build/C/man2/clone.2:965 build/C/man2/kcmp.2:178 build/C/man2/sched_get_priority_max.2:109 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_setparam.2:97 build/C/man2/sched_setscheduler.2:433 build/C/man2/setns.2:82 build/C/man2/unshare.2:213
1668 #: build/C/man2/clone.2:894
1670 "B<CLONE_SIGHAND> was specified, but B<CLONE_VM> was not. (Since Linux "
1677 #. .B CLONE_DETACHED
1681 #. (Since Linux 2.6.0-test6.)
1683 #: build/C/man2/clone.2:909
1685 "B<CLONE_THREAD> was specified, but B<CLONE_SIGHAND> was not. (Since Linux "
1690 #: build/C/man2/clone.2:917
1691 msgid "Both B<CLONE_FS> and B<CLONE_NEWNS> were specified in I<flags>."
1695 #: build/C/man2/clone.2:925
1696 msgid "Both B<CLONE_NEWIPC> and B<CLONE_SYSVSEM> were specified in I<flags>."
1700 #: build/C/man2/clone.2:933
1701 msgid "Both B<CLONE_NEWPID> and B<CLONE_THREAD> were specified in I<flags>."
1705 #: build/C/man2/clone.2:939
1706 msgid "Returned by B<clone>() when a zero value is specified for I<child_stack>."
1710 #: build/C/man2/clone.2:949
1712 "B<CLONE_NEWIPC> was specified in I<flags>, but the kernel was not configured "
1713 "with the B<CONFIG_SYSVIPC> and B<CONFIG_IPC_NS> options."
1717 #: build/C/man2/clone.2:957
1719 "B<CLONE_NEWNET> was specified in I<flags>, but the kernel was not configured "
1720 "with the B<CONFIG_NET_NS> option."
1724 #: build/C/man2/clone.2:965
1726 "B<CLONE_NEWPID> was specified in I<flags>, but the kernel was not configured "
1727 "with the B<CONFIG_PID_NS> option."
1731 #: build/C/man2/clone.2:973
1733 "B<CLONE_NEWUTS> was specified in I<flags>, but the kernel was not configured "
1734 "with the B<CONFIG_UTS> option."
1738 #: build/C/man2/clone.2:973 build/C/man2/setns.2:89 build/C/man2/unshare.2:217
1744 #: build/C/man2/clone.2:978
1746 "Cannot allocate sufficient memory to allocate a task structure for the "
1747 "child, or to copy those parts of the caller's context that need to be "
1752 #: build/C/man2/clone.2:978 build/C/man2/clone.2:987 build/C/man2/kcmp.2:182 build/C/man2/sched_setaffinity.2:135 build/C/man2/sched_setparam.2:101 build/C/man2/sched_setscheduler.2:438 build/C/man2/setns.2:92 build/C/man2/unshare.2:221
1758 #: build/C/man2/clone.2:987
1760 "B<CLONE_NEWIPC>, B<CLONE_NEWNET>, B<CLONE_NEWNS>, B<CLONE_NEWPID>, or "
1761 "B<CLONE_NEWUTS> was specified by an unprivileged process (process without "
1762 "B<CAP_SYS_ADMIN>)."
1766 #: build/C/man2/clone.2:991
1767 msgid "B<CLONE_PID> was specified by a process other than process 0."
1771 #: build/C/man2/clone.2:998
1773 "There is no entry for B<clone>() in libc5. glibc2 provides B<clone>() as "
1774 "described in this manual page."
1778 #: build/C/man2/clone.2:1002
1780 "B<clone>() is Linux-specific and should not be used in programs intended to "
1785 #: build/C/man2/clone.2:1012
1787 "In the kernel 2.4.x series, B<CLONE_THREAD> generally does not make the "
1788 "parent of the new thread the same as the parent of the calling process. "
1789 "However, for kernel versions 2.4.7 to 2.4.18 the B<CLONE_THREAD> flag "
1790 "implied the B<CLONE_PARENT> flag (as in kernel 2.6)."
1794 #: build/C/man2/clone.2:1022
1796 "For a while there was B<CLONE_DETACHED> (introduced in 2.5.32): parent wants "
1797 "no child-exit signal. In 2.6.2 the need to give this together with "
1798 "B<CLONE_THREAD> disappeared. This flag is still defined, but has no effect."
1802 #: build/C/man2/clone.2:1027
1804 "On i386, B<clone>() should not be called through vsyscall, but directly "
1805 "through I<int $0x80>."
1809 #: build/C/man2/clone.2:1058
1811 "Versions of the GNU C library that include the NPTL threading library "
1812 "contain a wrapper function for B<getpid>(2) that performs caching of PIDs. "
1813 "This caching relies on support in the glibc wrapper for B<clone>(), but as "
1814 "currently implemented, the cache may not be up to date in some "
1815 "circumstances. In particular, if a signal is delivered to the child "
1816 "immediately after the B<clone>() call, then a call to B<getpid>(2) in a "
1817 "handler for the signal may return the PID of the calling process (\"the "
1818 "parent\"), if the clone wrapper has not yet had a chance to update the PID "
1819 "cache in the child. (This discussion ignores the case where the child was "
1820 "created using B<CLONE_THREAD>, when B<getpid>(2) I<should> return the same "
1821 "value in the child and in the process that called B<clone>(), since the "
1822 "caller and the child are in the same thread group. The stale-cache problem "
1823 "also does not occur if the I<flags> argument includes B<CLONE_VM>.) To get "
1824 "the truth, it may be necessary to use code such as the following:"
1828 #: build/C/man2/clone.2:1061
1830 msgid " #include E<lt>syscall.hE<gt>\n"
1834 #: build/C/man2/clone.2:1063
1836 msgid " pid_t mypid;\n"
1840 #: build/C/man2/clone.2:1065
1842 msgid " mypid = syscall(SYS_getpid);\n"
1846 #: build/C/man2/clone.2:1070
1848 msgid "Create a child that executes in a separate UTS namespace"
1852 #: build/C/man2/clone.2:1080
1854 "The following program demonstrates the use of B<clone>() to create a child "
1855 "process that executes in a separate UTS namespace. The child changes the "
1856 "hostname in its UTS namespace. Both parent and child then display the "
1857 "system hostname, making it possible to see that the hostname differs in the "
1858 "UTS namespaces of the parent and child. For an example of the use of this "
1859 "program, see B<setns>(2)."
1863 #: build/C/man2/clone.2:1090
1866 "#define _GNU_SOURCE\n"
1867 "#include E<lt>sys/wait.hE<gt>\n"
1868 "#include E<lt>sys/utsname.hE<gt>\n"
1869 "#include E<lt>sched.hE<gt>\n"
1870 "#include E<lt>string.hE<gt>\n"
1871 "#include E<lt>stdio.hE<gt>\n"
1872 "#include E<lt>stdlib.hE<gt>\n"
1873 "#include E<lt>unistd.hE<gt>\n"
1877 #: build/C/man2/clone.2:1093 build/C/man2/setns.2:177
1880 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\e\n"
1885 #: build/C/man2/clone.2:1098
1888 "static int /* Start function for cloned child */\n"
1889 "childFunc(void *arg)\n"
1891 " struct utsname uts;\n"
1895 #: build/C/man2/clone.2:1100
1897 msgid " /* Change hostname in UTS namespace of child */\n"
1901 #: build/C/man2/clone.2:1103
1904 " if (sethostname(arg, strlen(arg)) == -1)\n"
1905 " errExit(\"sethostname\");\n"
1909 #: build/C/man2/clone.2:1105
1911 msgid " /* Retrieve and display hostname */\n"
1915 #: build/C/man2/clone.2:1109
1918 " if (uname(&uts) == -1)\n"
1919 " errExit(\"uname\");\n"
1920 " printf(\"uts.nodename in child: %s\\en\", uts.nodename);\n"
1924 #: build/C/man2/clone.2:1113
1927 " /* Keep the namespace open for a while, by sleeping.\n"
1928 " This allows some experimentation--for example, another\n"
1929 " process might join the namespace. */\n"
1933 #: build/C/man2/clone.2:1115
1935 msgid " sleep(200);\n"
1939 #: build/C/man2/clone.2:1118
1942 " return 0; /* Child terminates now */\n"
1947 #: build/C/man2/clone.2:1120
1949 msgid "#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */\n"
1953 #: build/C/man2/clone.2:1128
1957 "main(int argc, char *argv[])\n"
1959 " char *stack; /* Start of stack buffer */\n"
1960 " char *stackTop; /* End of stack buffer */\n"
1962 " struct utsname uts;\n"
1966 #: build/C/man2/clone.2:1133
1969 " if (argc E<lt> 2) {\n"
1970 " fprintf(stderr, \"Usage: %s E<lt>child-hostnameE<gt>\\en\", "
1972 " exit(EXIT_SUCCESS);\n"
1977 #: build/C/man2/clone.2:1135
1979 msgid " /* Allocate stack for child */\n"
1983 #: build/C/man2/clone.2:1140
1986 " stack = malloc(STACK_SIZE);\n"
1987 " if (stack == NULL)\n"
1988 " errExit(\"malloc\");\n"
1989 " stackTop = stack + STACK_SIZE; /* Assume stack grows downward */\n"
1993 #: build/C/man2/clone.2:1143
1996 " /* Create child that has its own UTS namespace;\n"
1997 " child commences execution in childFunc() */\n"
2001 #: build/C/man2/clone.2:1148
2004 " pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);\n"
2006 " errExit(\"clone\");\n"
2007 " printf(\"clone() returned %ld\\en\", (long) pid);\n"
2011 #: build/C/man2/clone.2:1150
2013 msgid " /* Parent falls through to here */\n"
2017 #: build/C/man2/clone.2:1152
2019 msgid " sleep(1); /* Give child time to change its hostname */\n"
2023 #: build/C/man2/clone.2:1155
2026 " /* Display hostname in parent\\(aqs UTS namespace. This will be\n"
2027 " different from hostname in child\\(aqs UTS namespace. */\n"
2031 #: build/C/man2/clone.2:1159
2034 " if (uname(&uts) == -1)\n"
2035 " errExit(\"uname\");\n"
2036 " printf(\"uts.nodename in parent: %s\\en\", uts.nodename);\n"
2040 #: build/C/man2/clone.2:1163
2043 " if (waitpid(pid, NULL, 0) == -1) /* Wait for child */\n"
2044 " errExit(\"waitpid\");\n"
2045 " printf(\"child has terminated\\en\");\n"
2049 #: build/C/man2/clone.2:1166
2052 " exit(EXIT_SUCCESS);\n"
2057 #: build/C/man2/clone.2:1181
2059 "B<fork>(2), B<futex>(2), B<getpid>(2), B<gettid>(2), B<kcmp>(2), "
2060 "B<set_thread_area>(2), B<set_tid_address>(2), B<setns>(2), B<tkill>(2), "
2061 "B<unshare>(2), B<wait>(2), B<capabilities>(7), B<pthreads>(7)"
2065 #: build/C/man2/kcmp.2:28
2071 #: build/C/man2/kcmp.2:28
2077 #: build/C/man2/kcmp.2:31
2078 msgid "kcmp - compare two processes to determine if they share a kernel resource"
2082 #: build/C/man2/kcmp.2:34
2084 msgid "B<#include E<lt>linux/kcmp.hE<gt>>\n"
2088 #: build/C/man2/kcmp.2:37
2091 "B<int kcmp(pid_t >I<pid1>B<, pid_t >I<pid2>B<, int >I<type>B<,>\n"
2092 "B< unsigned long >I<idx1>B<, unsigned long >I<idx2>B<);>\n"
2096 #: build/C/man2/kcmp.2:41
2097 msgid "I<Note>: There is no glibc wrapper for this system call; see NOTES."
2101 #: build/C/man2/kcmp.2:50
2103 "The B<kcmp>() system call can be used to check whether the two processes "
2104 "identified by I<pid1> and I<pid2> share a kernel resource such as virtual "
2105 "memory, file descriptors, and so on."
2109 #: build/C/man2/kcmp.2:55
2111 "The I<type> argument specifies which resource is to be compared in the two "
2112 "processes. It has one of the following values:"
2116 #: build/C/man2/kcmp.2:55
2118 msgid "B<KCMP_FILE>"
2122 #: build/C/man2/kcmp.2:67
2124 "Check whether a file descriptor I<idx1> in the process I<pid1> refers to the "
2125 "same open file description (see B<open>(2)) as file descriptor I<idx2> in "
2126 "the process I<pid2>."
2130 #: build/C/man2/kcmp.2:67
2132 msgid "B<KCMP_FILES>"
2136 #: build/C/man2/kcmp.2:75
2138 "Check whether the process share the same set of open file descriptors. The "
2139 "arguments I<idx1> and I<idx2> are ignored."
2143 #: build/C/man2/kcmp.2:75
2149 #: build/C/man2/kcmp.2:84
2151 "Check whether the processes share the same file system information (i.e., "
2152 "file mode creation mask, working directory, and file system root). The "
2153 "arguments I<idx1> and I<idx2> are ignored."
2157 #: build/C/man2/kcmp.2:84
2163 #: build/C/man2/kcmp.2:92
2165 "Check whether the processes share I/O context. The arguments I<idx1> and "
2166 "I<idx2> are ignored."
2170 #: build/C/man2/kcmp.2:92
2172 msgid "B<KCMP_SIGHAND>"
2176 #: build/C/man2/kcmp.2:100
2178 "Check whether the processes share the same table of signal dispositions. "
2179 "The arguments I<idx1> and I<idx2> are ignored."
2183 #: build/C/man2/kcmp.2:100
2185 msgid "B<KCMP_SYSVSEM>"
2189 #: build/C/man2/kcmp.2:109
2191 "Check whether the processes share the same list of System V semaphore undo "
2192 "operations. The arguments I<idx1> and I<idx2> are ignored."
2196 #: build/C/man2/kcmp.2:109
2202 #: build/C/man2/kcmp.2:117
2204 "Check whether the processes share the same address space. The arguments "
2205 "I<idx1> and I<idx2> are ignored."
2209 #: build/C/man2/kcmp.2:124
2211 "Note the B<kcmp>() is not protected against false positives which may have "
2212 "place if tasks are running. Which means one should stop tasks being "
2213 "inspected with this syscall to obtain meaningful results."
2217 #: build/C/man2/kcmp.2:130
2219 "The return value of a successful call to B<kcmp>() is simply the result of "
2220 "arithmetic comparison of kernel pointers (when the kernel compares "
2221 "resources, it uses their memory addresses)."
2225 #: build/C/man2/kcmp.2:138
2227 "The easiest way to explain is to consider an example. Suppose that I<v1> "
2228 "and I<v2> are the addresses of appropriate resources, then the return value "
2229 "is one of the following:"
2233 #: build/C/man2/kcmp.2:139
2239 #: build/C/man2/kcmp.2:144
2241 "I<v1> is equal to I<v2>; in other words, the two processes share the "
2246 #: build/C/man2/kcmp.2:144
2252 #: build/C/man2/kcmp.2:148
2253 msgid "I<v1> is less than I<v2>."
2257 #: build/C/man2/kcmp.2:148
2263 #: build/C/man2/kcmp.2:152
2264 msgid "I<v1> is greater than I<v2>."
2268 #: build/C/man2/kcmp.2:152
2274 #: build/C/man2/kcmp.2:157
2275 msgid "I<v1> is not equal to I<v2>, but ordering information is unavailable."
2279 #: build/C/man2/kcmp.2:162
2280 msgid "On error, -1 is returned, and I<errno> is set appropriately."
2284 #: build/C/man2/kcmp.2:167
2286 "B<kcmp ()> was designed to return values suitable for sorting. This is "
2287 "particularly handy if one needs to compare a large number of file "
2292 #: build/C/man2/kcmp.2:168 build/C/man2/setns.2:78
2298 #: build/C/man2/kcmp.2:178
2299 msgid "I<type> is B<KCMP_FILE> and I<fd1> or I<fd2> is not an open file descriptor."
2303 #: build/C/man2/kcmp.2:182
2304 msgid "I<type> is invalid."
2308 #: build/C/man2/kcmp.2:188
2310 "Insufficient permission to inspect process resources. The B<CAP_SYS_PTRACE> "
2311 "capability is required to inspect processes that you do not own."
2315 #: build/C/man2/kcmp.2:188 build/C/man2/sched_rr_get_interval.2:90 build/C/man2/sched_setaffinity.2:145 build/C/man2/sched_setparam.2:107 build/C/man2/sched_setscheduler.2:441
2321 #: build/C/man2/kcmp.2:195
2322 msgid "Process I<pid1> or I<pid2> does not exist."
2326 #: build/C/man2/kcmp.2:199
2327 msgid "The B<kcmp>() system call first appeared in Linux 3.5."
2331 #: build/C/man2/kcmp.2:202
2333 "B<kcmp>() is Linux specific and should not be used in programs intended to "
2338 #: build/C/man2/kcmp.2:205
2340 "Glibc does not provide a wrapper for this system call; call it using "
2345 #: build/C/man2/kcmp.2:214
2347 "This system call is available only if the kernel was configured with "
2348 "B<CONFIG_CHECKPOINT_RESTORE>. The main use of the system call is for the "
2349 "checkpoint/restore in user space (CRIU) feature. The alternative to this "
2350 "system call would have been to expose suitable process information via the "
2351 "B<proc>(5) file system; this was deemed to be unsuitable for security "
2356 #: build/C/man2/kcmp.2:219
2358 "See B<clone>(2) for some background information on the shared resources "
2359 "referred to on this page."
2363 #: build/C/man2/kcmp.2:222
2364 msgid "B<clone>(2), B<unshare>(2)"
2368 #: build/C/man2/sched_get_priority_max.2:29
2370 msgid "SCHED_GET_PRIORITY_MAX"
2374 #: build/C/man2/sched_get_priority_max.2:29
2380 #: build/C/man2/sched_get_priority_max.2:32
2381 msgid "sched_get_priority_max, sched_get_priority_min - get static priority range"
2385 #: 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
2386 msgid "B<#include E<lt>sched.hE<gt>>"
2390 #: build/C/man2/sched_get_priority_max.2:36
2391 msgid "B<int sched_get_priority_max(int >I<policy>B<);>"
2395 #: build/C/man2/sched_get_priority_max.2:38
2396 msgid "B<int sched_get_priority_min(int >I<policy>B<);>"
2400 #: build/C/man2/sched_get_priority_max.2:57
2402 "B<sched_get_priority_max>() returns the maximum priority value that can be "
2403 "used with the scheduling algorithm identified by I<policy>. "
2404 "B<sched_get_priority_min>() returns the minimum priority value that can be "
2405 "used with the scheduling algorithm identified by I<policy>. Supported "
2406 "I<policy> values are B<SCHED_FIFO>, B<SCHED_RR>, B<SCHED_OTHER>, and "
2407 "B<SCHED_BATCH>. Further details about these policies can be found in "
2408 "B<sched_setscheduler>(2)."
2412 #: build/C/man2/sched_get_priority_max.2:66
2414 "Processes with numerically higher priority values are scheduled before "
2415 "processes with numerically lower priority values. Thus, the value returned "
2416 "by B<sched_get_priority_max>() will be greater than the value returned by "
2417 "B<sched_get_priority_min>()."
2421 #: build/C/man2/sched_get_priority_max.2:77
2423 "Linux allows the static priority value range 1 to 99 for B<SCHED_FIFO> and "
2424 "B<SCHED_RR> and the priority 0 for B<SCHED_OTHER> and B<SCHED_BATCH>. "
2425 "Scheduling priority ranges for the various policies are not alterable."
2429 #: build/C/man2/sched_get_priority_max.2:89
2431 "The range of scheduling priorities may vary on other POSIX systems, thus it "
2432 "is a good idea for portable applications to use a virtual priority range and "
2433 "map it to the interval given by B<sched_get_priority_max>() and "
2434 "B<sched_get_priority_min>(). POSIX.1-2001 requires a spread of at least 32 "
2435 "between the maximum and the minimum values for B<SCHED_FIFO> and "
2440 #: build/C/man2/sched_get_priority_max.2:98
2442 "POSIX systems on which B<sched_get_priority_max>() and "
2443 "B<sched_get_priority_min>() are available define "
2444 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2448 #: build/C/man2/sched_get_priority_max.2:108
2450 "On success, B<sched_get_priority_max>() and B<sched_get_priority_min>() "
2451 "return the maximum/minimum priority value for the named scheduling policy. "
2452 "On error, -1 is returned, and I<errno> is set appropriately."
2456 #: build/C/man2/sched_get_priority_max.2:114
2457 msgid "The argument I<policy> does not identify a defined scheduling policy."
2461 #: build/C/man2/sched_get_priority_max.2:116 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setparam.2:112 build/C/man2/sched_yield.2:54
2462 msgid "POSIX.1-2001."
2466 #: build/C/man2/sched_get_priority_max.2:125
2468 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_getscheduler>(2), "
2469 "B<sched_setaffinity>(2), B<sched_setparam>(2), B<sched_setscheduler>(2)"
2473 #: build/C/man2/sched_get_priority_max.2:128 build/C/man2/sched_rr_get_interval.2:138 build/C/man2/sched_setparam.2:134 build/C/man2/sched_setscheduler.2:563 build/C/man2/sched_yield.2:85
2475 "I<Programming for the real world - POSIX.4> by Bill O. Gallmeister, O'Reilly "
2476 "& Associates, Inc., ISBN 1-56592-074-0."
2480 #: build/C/man3/sched_getcpu.3:26
2482 msgid "SCHED_GETCPU"
2486 #: build/C/man3/sched_getcpu.3:26 build/C/man2/unshare.2:20
2492 #: build/C/man3/sched_getcpu.3:29
2493 msgid "sched_getcpu - determine CPU on which the calling thread is running"
2497 #: build/C/man3/sched_getcpu.3:34
2499 msgid "B<int sched_getcpu(void);>\n"
2503 #: build/C/man3/sched_getcpu.3:39 build/C/man2/unshare.2:33
2504 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
2508 #: build/C/man3/sched_getcpu.3:42
2509 msgid "B<sched_getcpu>():"
2513 #: build/C/man3/sched_getcpu.3:58
2515 "B<sched_getcpu>() returns the number of the CPU on which the calling thread "
2516 "is currently executing."
2520 #: build/C/man3/sched_getcpu.3:65
2522 "On success, B<sched_getcpu>() returns a nonnegative CPU number. On error, "
2523 "-1 is returned and I<errno> is set to indicate the error."
2527 #: build/C/man3/sched_getcpu.3:66 build/C/man2/sched_rr_get_interval.2:87
2533 #: build/C/man3/sched_getcpu.3:70
2534 msgid "This kernel does not implement B<getcpu>(2)."
2538 #: build/C/man3/sched_getcpu.3:72
2539 msgid "This function is available since glibc 2.6."
2543 #: build/C/man3/sched_getcpu.3:75
2544 msgid "B<sched_getcpu>() is glibc specific."
2548 #: build/C/man3/sched_getcpu.3:77
2553 #: build/C/man3/sched_getcpu.3:81
2555 msgid "cpu = sched_getcpu();\n"
2559 #: build/C/man3/sched_getcpu.3:87
2560 msgid "is equivalent to the following B<getcpu>(2) call:"
2564 #: build/C/man3/sched_getcpu.3:93
2568 "s = getcpu(&c, NULL, NULL);\n"
2569 "cpu = (s == -1) ? s : c;\n"
2573 #: build/C/man3/sched_getcpu.3:97
2574 msgid "B<getcpu>(2)"
2578 #: build/C/man2/sched_rr_get_interval.2:29
2580 msgid "SCHED_RR_GET_INTERVAL"
2584 #: build/C/man2/sched_rr_get_interval.2:29
2590 #: build/C/man2/sched_rr_get_interval.2:32
2591 msgid "sched_rr_get_interval - get the SCHED_RR interval for the named process"
2595 #: build/C/man2/sched_rr_get_interval.2:36
2596 msgid "B<int sched_rr_get_interval(pid_t >I<pid>B<, struct timespec * >I<tp>B<);>"
2600 #: build/C/man2/sched_rr_get_interval.2:47
2602 "B<sched_rr_get_interval>() writes into the I<timespec> structure pointed to "
2603 "by I<tp> the round-robin time quantum for the process identified by I<pid>. "
2604 "The specified process should be running under the B<SCHED_RR> scheduling "
2609 #: build/C/man2/sched_rr_get_interval.2:51
2610 msgid "The I<timespec> structure has the following form:"
2614 #: build/C/man2/sched_rr_get_interval.2:58
2617 "struct timespec {\n"
2618 " time_t tv_sec; /* seconds */\n"
2619 " long tv_nsec; /* nanoseconds */\n"
2623 #. FIXME . On Linux, sched_rr_get_interval()
2624 #. returns the timeslice for SCHED_OTHER processes -- this timeslice
2625 #. is influenced by the nice value.
2626 #. For SCHED_FIFO processes, this always returns 0.
2628 #. The round-robin time quantum value is not alterable under Linux
2631 #: build/C/man2/sched_rr_get_interval.2:73
2633 "If I<pid> is zero, the time quantum for the calling process is written into "
2638 #: build/C/man2/sched_rr_get_interval.2:80
2640 "On success, B<sched_rr_get_interval>() returns 0. On error, -1 is "
2641 "returned, and I<errno> is set appropriately."
2645 #: build/C/man2/sched_rr_get_interval.2:81 build/C/man2/sched_setaffinity.2:117
2651 #: build/C/man2/sched_rr_get_interval.2:84
2652 msgid "Problem with copying information to user space."
2656 #: build/C/man2/sched_rr_get_interval.2:87
2657 msgid "Invalid pid."
2661 #: build/C/man2/sched_rr_get_interval.2:90
2662 msgid "The system call is not yet implemented (only on rather old kernels)."
2666 #: build/C/man2/sched_rr_get_interval.2:94
2667 msgid "Could not find a process with the ID I<pid>."
2671 #: build/C/man2/sched_rr_get_interval.2:103
2673 "POSIX systems on which B<sched_rr_get_interval>() is available define "
2674 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2678 #: build/C/man2/sched_rr_get_interval.2:103
2683 #. commit a4ec24b48ddef1e93f7578be53270f0b95ad666c
2685 #: build/C/man2/sched_rr_get_interval.2:117
2687 "POSIX does not specify any mechanism for controlling the size of the "
2688 "round-robin time quantum. Older Linux kernels provide a (nonportable) "
2689 "method of doing this. The quantum can be controlled by adjusting the "
2690 "process's nice value (see B<setpriority>(2)). Assigning a negative (i.e., "
2691 "high) nice value results in a longer quantum; assigning a positive (i.e., "
2692 "low) nice value results in a shorter quantum. The default quantum is 0.1 "
2693 "seconds; the degree to which changing the nice value affects the quantum has "
2694 "varied somewhat across kernel versions. This method of adjusting the "
2695 "quantum was removed starting with Linux 2.6.24."
2698 #. commit ce0dbbbb30aee6a835511d5be446462388ba9eee
2700 #. As of Linux 1.3.81
2701 #. .BR sched_rr_get_interval ()
2702 #. returns with error
2703 #. ENOSYS, because SCHED_RR has not yet been fully implemented and tested
2706 #: build/C/man2/sched_rr_get_interval.2:132
2708 "Linux 3.9 added a new mechanism for adjusting (and viewing) the B<SCHED_RR> "
2709 "quantum: the I</proc/sys/kernel/sched_rr_timeslice_ms> file exposes the "
2710 "quantum as a millisecond value, whose default is 100. Writing 0 to this "
2711 "file resets the quantum to the default value."
2715 #: build/C/man2/sched_rr_get_interval.2:135 build/C/man2/sched_setaffinity.2:177
2716 msgid "B<sched_setscheduler>(2) has a description of the Linux scheduling scheme."
2720 #: build/C/man2/sched_setaffinity.2:34
2722 msgid "SCHED_SETAFFINITY"
2726 #: build/C/man2/sched_setaffinity.2:34
2732 #: build/C/man2/sched_setaffinity.2:38
2734 "sched_setaffinity, sched_getaffinity - set and get a process's CPU affinity "
2739 #: build/C/man2/sched_setaffinity.2:45
2742 "B<int sched_setaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2743 "B< cpu_set_t *>I<mask>B<);>\n"
2747 #: build/C/man2/sched_setaffinity.2:48
2750 "B<int sched_getaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2751 "B< cpu_set_t *>I<mask>B<);>\n"
2755 #: build/C/man2/sched_setaffinity.2:63
2757 "A process's CPU affinity mask determines the set of CPUs on which it is "
2758 "eligible to run. On a multiprocessor system, setting the CPU affinity mask "
2759 "can be used to obtain performance benefits. For example, by dedicating one "
2760 "CPU to a particular process (i.e., setting the affinity mask of that process "
2761 "to specify a single CPU, and setting the affinity mask of all other "
2762 "processes to exclude that CPU), it is possible to ensure maximum execution "
2763 "speed for that process. Restricting a process to run on a single CPU also "
2764 "avoids the performance cost caused by the cache invalidation that occurs "
2765 "when a process ceases to execute on one CPU and then recommences execution "
2766 "on a different CPU."
2770 #: build/C/man2/sched_setaffinity.2:70
2772 "A CPU affinity mask is represented by the I<cpu_set_t> structure, a \"CPU "
2773 "set\", pointed to by I<mask>. A set of macros for manipulating CPU sets is "
2774 "described in B<CPU_SET>(3)."
2778 #: build/C/man2/sched_setaffinity.2:85
2780 "B<sched_setaffinity>() sets the CPU affinity mask of the process whose ID "
2781 "is I<pid> to the value specified by I<mask>. If I<pid> is zero, then the "
2782 "calling process is used. The argument I<cpusetsize> is the length (in "
2783 "bytes) of the data pointed to by I<mask>. Normally this argument would be "
2784 "specified as I<sizeof(cpu_set_t)>."
2788 #: build/C/man2/sched_setaffinity.2:92
2790 "If the process specified by I<pid> is not currently running on one of the "
2791 "CPUs specified in I<mask>, then that process is migrated to one of the CPUs "
2792 "specified in I<mask>."
2796 #: build/C/man2/sched_setaffinity.2:107
2798 "B<sched_getaffinity>() writes the affinity mask of the process whose ID is "
2799 "I<pid> into the I<cpu_set_t> structure pointed to by I<mask>. The "
2800 "I<cpusetsize> argument specifies the size (in bytes) of I<mask>. If I<pid> "
2801 "is zero, then the mask of the calling process is returned."
2805 #: build/C/man2/sched_setaffinity.2:116
2807 "On success, B<sched_setaffinity>() and B<sched_getaffinity>() return 0. "
2808 "On error, -1 is returned, and I<errno> is set appropriately."
2812 #: build/C/man2/sched_setaffinity.2:120
2813 msgid "A supplied memory address was invalid."
2817 #: build/C/man2/sched_setaffinity.2:128
2819 "The affinity bit mask I<mask> contains no processors that are currently "
2820 "physically on the system and permitted to the process according to any "
2821 "restrictions that may be imposed by the \"cpuset\" mechanism described in "
2826 #: build/C/man2/sched_setaffinity.2:135
2828 "(B<sched_getaffinity>() and, in kernels before 2.6.9, "
2829 "B<sched_setaffinity>()) I<cpusetsize> is smaller than the size of the "
2830 "affinity mask used by the kernel."
2834 #: build/C/man2/sched_setaffinity.2:145
2836 "(B<sched_setaffinity>()) The calling process does not have appropriate "
2837 "privileges. The caller needs an effective user ID equal to the real user ID "
2838 "or effective user ID of the process identified by I<pid>, or it must possess "
2839 "the B<CAP_SYS_NICE> capability."
2843 #: build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setparam.2:110 build/C/man2/sched_setscheduler.2:444
2844 msgid "The process whose ID is I<pid> could not be found."
2848 #: build/C/man2/sched_setaffinity.2:159
2850 "The CPU affinity system calls were introduced in Linux kernel 2.5.8. The "
2851 "system call wrappers were introduced in glibc 2.3. Initially, the glibc "
2852 "interfaces included a I<cpusetsize> argument, typed as I<unsigned int>. In "
2853 "glibc 2.3.3, the I<cpusetsize> argument was removed, but was then restored "
2854 "in glibc 2.3.4, with type I<size_t>."
2858 #: build/C/man2/sched_setaffinity.2:161
2859 msgid "These system calls are Linux-specific."
2863 #: build/C/man2/sched_setaffinity.2:174
2865 "After a call to B<sched_setaffinity>(), the set of CPUs on which the process "
2866 "will actually run is the intersection of the set specified in the I<mask> "
2867 "argument and the set of CPUs actually present on the system. The system may "
2868 "further restrict the set of CPUs on which the process runs if the \"cpuset\" "
2869 "mechanism described in B<cpuset>(7) is being used. These restrictions on "
2870 "the actual set of CPUs on which the process will run are silently imposed by "
2875 #: build/C/man2/sched_setaffinity.2:194
2877 "The affinity mask is actually a per-thread attribute that can be adjusted "
2878 "independently for each of the threads in a thread group. The value returned "
2879 "from a call to B<gettid>(2) can be passed in the argument I<pid>. "
2880 "Specifying I<pid> as 0 will set the attribute for the calling thread, and "
2881 "passing the value returned from a call to B<getpid>(2) will set the "
2882 "attribute for the main thread of the thread group. (If you are using the "
2883 "POSIX threads API, then use B<pthread_setaffinity_np>(3) instead of "
2884 "B<sched_setaffinity>().)"
2888 #: build/C/man2/sched_setaffinity.2:200
2890 "A child created via B<fork>(2) inherits its parent's CPU affinity mask. "
2891 "The affinity mask is preserved across an B<execve>(2)."
2895 #: build/C/man2/sched_setaffinity.2:214
2897 "This manual page describes the glibc interface for the CPU affinity calls. "
2898 "The actual system call interface is slightly different, with the I<mask> "
2899 "being typed as I<unsigned long\\ *>, reflecting the fact that the underlying "
2900 "implementation of CPU sets is a simple bit mask. On success, the raw "
2901 "B<sched_getaffinity>() system call returns the size (in bytes) of the "
2902 "I<cpumask_t> data type that is used internally by the kernel to represent "
2903 "the CPU set bit mask."
2907 #: build/C/man2/sched_setaffinity.2:233
2909 "B<taskset>(1), B<clone>(2), B<getcpu>(2), B<getpriority>(2), B<gettid>(2), "
2910 "B<nice>(2), B<sched_get_priority_max>(2), B<sched_get_priority_min>(2), "
2911 "B<sched_getscheduler>(2), B<sched_setscheduler>(2), B<setpriority>(2), "
2912 "B<CPU_SET>(3), B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), "
2913 "B<capabilities>(7), B<cpuset>(7)"
2917 #: build/C/man2/sched_setparam.2:30
2919 msgid "SCHED_SETPARAM"
2923 #: build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:46
2929 #: build/C/man2/sched_setparam.2:33
2930 msgid "sched_setparam, sched_getparam - set and get scheduling parameters"
2934 #: build/C/man2/sched_setparam.2:38
2937 "B<int sched_setparam(pid_t >I<pid>B<, const struct sched_param "
2942 #: build/C/man2/sched_setparam.2:40
2944 msgid "B<int sched_getparam(pid_t >I<pid>B<, struct sched_param *>I<param>B<);>\n"
2948 #: build/C/man2/sched_setparam.2:46 build/C/man2/sched_setscheduler.2:65
2951 "B<struct sched_param {\n"
2953 " int >I<sched_priority>B<;\n"
2959 #: build/C/man2/sched_setparam.2:60
2961 "B<sched_setparam>() sets the scheduling parameters associated with the "
2962 "scheduling policy for the process identified by I<pid>. If I<pid> is zero, "
2963 "then the parameters of the calling process are set. The interpretation of "
2964 "the argument I<param> depends on the scheduling policy of the process "
2965 "identified by I<pid>. See B<sched_setscheduler>(2) for a description of "
2966 "the scheduling policies supported under Linux."
2970 #: build/C/man2/sched_setparam.2:66
2972 "B<sched_getparam>() retrieves the scheduling parameters for the process "
2973 "identified by I<pid>. If I<pid> is zero, then the parameters of the calling "
2974 "process are retrieved."
2978 #: build/C/man2/sched_setparam.2:75
2980 "B<sched_setparam>() checks the validity of I<param> for the scheduling "
2981 "policy of the process. The value I<param-E<gt>sched_priority> must lie "
2982 "within the range given by B<sched_get_priority_min>(2) and "
2983 "B<sched_get_priority_max>(2)."
2987 #: build/C/man2/sched_setparam.2:79
2989 "For a discussion of the privileges and resource limits related to scheduling "
2990 "priority and policy, see B<sched_setscheduler>(2)."
2994 #: build/C/man2/sched_setparam.2:87
2996 "POSIX systems on which B<sched_setparam>() and B<sched_getparam>() are "
2997 "available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3001 #: build/C/man2/sched_setparam.2:96
3003 "On success, B<sched_setparam>() and B<sched_getparam>() return 0. On "
3004 "error, -1 is returned, and I<errno> is set appropriately."
3008 #: build/C/man2/sched_setparam.2:101
3009 msgid "The argument I<param> does not make sense for the current scheduling policy."
3013 #: build/C/man2/sched_setparam.2:107
3015 "The calling process does not have appropriate privileges (Linux: does not "
3016 "have the B<CAP_SYS_NICE> capability)."
3020 #: build/C/man2/sched_setparam.2:118
3022 "Scheduling parameters are in fact per-thread attributes on Linux; see "
3023 "B<sched_setscheduler>(2)."
3027 #: build/C/man2/sched_setparam.2:131
3029 "B<getpriority>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3030 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), "
3031 "B<sched_getscheduler>(2), B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
3032 "B<setpriority>(2), B<capabilities>(7)"
3036 #: build/C/man2/sched_setscheduler.2:46
3038 msgid "SCHED_SETSCHEDULER"
3042 #: build/C/man2/sched_setscheduler.2:50
3044 "sched_setscheduler, sched_getscheduler - set and get scheduling "
3049 #: build/C/man2/sched_setscheduler.2:55
3051 msgid "B<int sched_setscheduler(pid_t >I<pid>B<, int >I<policy>B<,>\n"
3055 #: build/C/man2/sched_setscheduler.2:57
3057 msgid "B< const struct sched_param *>I<param>B<);>\n"
3061 #: build/C/man2/sched_setscheduler.2:59
3063 msgid "B<int sched_getscheduler(pid_t >I<pid>B<);>\n"
3067 #: build/C/man2/sched_setscheduler.2:76
3069 "B<sched_setscheduler>() sets both the scheduling policy and the associated "
3070 "parameters for the process whose ID is specified in I<pid>. If I<pid> "
3071 "equals zero, the scheduling policy and parameters of the calling process "
3072 "will be set. The interpretation of the argument I<param> depends on the "
3073 "selected policy. Currently, Linux supports the following \"normal\" (i.e., "
3074 "non-real-time) scheduling policies:"
3078 #: build/C/man2/sched_setscheduler.2:76
3080 msgid "B<SCHED_OTHER>"
3083 #. In the 2.6 kernel sources, SCHED_OTHER is actually called
3086 #: build/C/man2/sched_setscheduler.2:81
3087 msgid "the standard round-robin time-sharing policy;"
3091 #: build/C/man2/sched_setscheduler.2:81
3093 msgid "B<SCHED_BATCH>"
3097 #: build/C/man2/sched_setscheduler.2:84
3098 msgid "for \"batch\" style execution of processes; and"
3102 #: build/C/man2/sched_setscheduler.2:84
3104 msgid "B<SCHED_IDLE>"
3108 #: build/C/man2/sched_setscheduler.2:89
3109 msgid "for running I<very> low priority background jobs."
3113 #: build/C/man2/sched_setscheduler.2:93
3115 "The following \"real-time\" policies are also supported, for special "
3116 "time-critical applications that need precise control over the way in which "
3117 "runnable processes are selected for execution:"
3121 #: build/C/man2/sched_setscheduler.2:93
3123 msgid "B<SCHED_FIFO>"
3127 #: build/C/man2/sched_setscheduler.2:96
3128 msgid "a first-in, first-out policy; and"
3132 #: build/C/man2/sched_setscheduler.2:96
3138 #: build/C/man2/sched_setscheduler.2:99
3139 msgid "a round-robin policy."
3143 #: build/C/man2/sched_setscheduler.2:101
3144 msgid "The semantics of each of these policies are detailed below."
3148 #: build/C/man2/sched_setscheduler.2:108
3150 "B<sched_getscheduler>() queries the scheduling policy currently applied to "
3151 "the process identified by I<pid>. If I<pid> equals zero, the policy of the "
3152 "calling process will be retrieved."
3156 #: build/C/man2/sched_setscheduler.2:108
3158 msgid "Scheduling policies"
3162 #: build/C/man2/sched_setscheduler.2:117
3164 "The scheduler is the kernel component that decides which runnable process "
3165 "will be executed by the CPU next. Each process has an associated scheduling "
3166 "policy and a I<static> scheduling priority, I<sched_priority>; these are the "
3167 "settings that are modified by B<sched_setscheduler>(). The scheduler makes "
3168 "it decisions based on knowledge of the scheduling policy and static priority "
3169 "of all processes on the system."
3173 #: build/C/man2/sched_setscheduler.2:122
3175 "For processes scheduled under one of the normal scheduling policies "
3176 "(B<SCHED_OTHER>, B<SCHED_IDLE>, B<SCHED_BATCH>), I<sched_priority> is not "
3177 "used in scheduling decisions (it must be specified as 0)."
3181 #: build/C/man2/sched_setscheduler.2:136
3183 "Processes scheduled under one of the real-time policies (B<SCHED_FIFO>, "
3184 "B<SCHED_RR>) have a I<sched_priority> value in the range 1 (low) to 99 "
3185 "(high). (As the numbers imply, real-time processes always have higher "
3186 "priority than normal processes.) Note well: POSIX.1-2001 requires an "
3187 "implementation to support only a minimum 32 distinct priority levels for the "
3188 "real-time policies, and some systems supply just this minimum. Portable "
3189 "programs should use B<sched_get_priority_min>(2) and "
3190 "B<sched_get_priority_max>(2) to find the range of priorities supported for "
3191 "a particular policy."
3195 #: build/C/man2/sched_setscheduler.2:142
3197 "Conceptually, the scheduler maintains a list of runnable processes for each "
3198 "possible I<sched_priority> value. In order to determine which process runs "
3199 "next, the scheduler looks for the nonempty list with the highest static "
3200 "priority and selects the process at the head of this list."
3204 #: build/C/man2/sched_setscheduler.2:146
3206 "A process's scheduling policy determines where it will be inserted into the "
3207 "list of processes with equal static priority and how it will move inside "
3212 #: build/C/man2/sched_setscheduler.2:154
3214 "All scheduling is preemptive: if a process with a higher static priority "
3215 "becomes ready to run, the currently running process will be preempted and "
3216 "returned to the wait list for its static priority level. The scheduling "
3217 "policy determines the ordering only within the list of runnable processes "
3218 "with equal static priority."
3222 #: build/C/man2/sched_setscheduler.2:154
3224 msgid "SCHED_FIFO: First in-first out scheduling"
3228 #: build/C/man2/sched_setscheduler.2:163
3230 "B<SCHED_FIFO> can be used only with static priorities higher than 0, which "
3231 "means that when a B<SCHED_FIFO> processes becomes runnable, it will always "
3232 "immediately preempt any currently running B<SCHED_OTHER>, B<SCHED_BATCH>, or "
3233 "B<SCHED_IDLE> process. B<SCHED_FIFO> is a simple scheduling algorithm "
3234 "without time slicing. For processes scheduled under the B<SCHED_FIFO> "
3235 "policy, the following rules apply:"
3239 #: build/C/man2/sched_setscheduler.2:163 build/C/man2/sched_setscheduler.2:168 build/C/man2/sched_setscheduler.2:171 build/C/man2/sched_setscheduler.2:185 build/C/man2/sched_setscheduler.2:287 build/C/man2/sched_setscheduler.2:295 build/C/man2/sched_setscheduler.2:336 build/C/man2/sched_setscheduler.2:344 build/C/man2/sched_setscheduler.2:349 build/C/man2/sched_setscheduler.2:354
3245 #: build/C/man2/sched_setscheduler.2:168
3247 "A B<SCHED_FIFO> process that has been preempted by another process of higher "
3248 "priority will stay at the head of the list for its priority and will resume "
3249 "execution as soon as all processes of higher priority are blocked again."
3253 #: build/C/man2/sched_setscheduler.2:171
3255 "When a B<SCHED_FIFO> process becomes runnable, it will be inserted at the "
3256 "end of the list for its priority."
3259 #. In 2.2.x and 2.4.x, the process is placed at the front of the queue
3260 #. In 2.0.x, the Right Thing happened: the process went to the back -- MTK
3262 #: build/C/man2/sched_setscheduler.2:185
3264 "A call to B<sched_setscheduler>() or B<sched_setparam>(2) will put the "
3265 "B<SCHED_FIFO> (or B<SCHED_RR>) process identified by I<pid> at the start of "
3266 "the list if it was runnable. As a consequence, it may preempt the currently "
3267 "running process if it has the same priority. (POSIX.1-2001 specifies that "
3268 "the process should go to the end of the list.)"
3272 #: build/C/man2/sched_setscheduler.2:189
3273 msgid "A process calling B<sched_yield>(2) will be put at the end of the list."
3277 #: build/C/man2/sched_setscheduler.2:193
3279 "No other events will move a process scheduled under the B<SCHED_FIFO> policy "
3280 "in the wait list of runnable processes with equal static priority."
3284 #: build/C/man2/sched_setscheduler.2:198
3286 "A B<SCHED_FIFO> process runs until either it is blocked by an I/O request, "
3287 "it is preempted by a higher priority process, or it calls B<sched_yield>(2)."
3291 #: build/C/man2/sched_setscheduler.2:198
3293 msgid "SCHED_RR: Round-robin scheduling"
3296 #. On Linux 2.4, the length of the RR interval is influenced
3297 #. by the process nice value -- MTK
3299 #: build/C/man2/sched_setscheduler.2:217
3301 "B<SCHED_RR> is a simple enhancement of B<SCHED_FIFO>. Everything described "
3302 "above for B<SCHED_FIFO> also applies to B<SCHED_RR>, except that each "
3303 "process is allowed to run only for a maximum time quantum. If a B<SCHED_RR> "
3304 "process has been running for a time period equal to or longer than the time "
3305 "quantum, it will be put at the end of the list for its priority. A "
3306 "B<SCHED_RR> process that has been preempted by a higher priority process and "
3307 "subsequently resumes execution as a running process will complete the "
3308 "unexpired portion of its round-robin time quantum. The length of the time "
3309 "quantum can be retrieved using B<sched_rr_get_interval>(2)."
3313 #: build/C/man2/sched_setscheduler.2:217
3315 msgid "SCHED_OTHER: Default Linux time-sharing scheduling"
3319 #: build/C/man2/sched_setscheduler.2:233
3321 "B<SCHED_OTHER> can be used at only static priority 0. B<SCHED_OTHER> is the "
3322 "standard Linux time-sharing scheduler that is intended for all processes "
3323 "that do not require the special real-time mechanisms. The process to run is "
3324 "chosen from the static priority 0 list based on a I<dynamic> priority that "
3325 "is determined only inside this list. The dynamic priority is based on the "
3326 "nice value (set by B<nice>(2) or B<setpriority>(2)) and increased for each "
3327 "time quantum the process is ready to run, but denied to run by the "
3328 "scheduler. This ensures fair progress among all B<SCHED_OTHER> processes."
3332 #: build/C/man2/sched_setscheduler.2:233
3334 msgid "SCHED_BATCH: Scheduling batch processes"
3338 #: build/C/man2/sched_setscheduler.2:245
3340 "(Since Linux 2.6.16.) B<SCHED_BATCH> can be used only at static priority "
3341 "0. This policy is similar to B<SCHED_OTHER> in that it schedules the "
3342 "process according to its dynamic priority (based on the nice value). The "
3343 "difference is that this policy will cause the scheduler to always assume "
3344 "that the process is CPU-intensive. Consequently, the scheduler will apply a "
3345 "small scheduling penalty with respect to wakeup behaviour, so that this "
3346 "process is mildly disfavored in scheduling decisions."
3349 #. The following paragraph is drawn largely from the text that
3350 #. accompanied Ingo Molnar's patch for the implementation of
3353 #: build/C/man2/sched_setscheduler.2:254
3355 "This policy is useful for workloads that are noninteractive, but do not want "
3356 "to lower their nice value, and for workloads that want a deterministic "
3357 "scheduling policy without interactivity causing extra preemptions (between "
3358 "the workload's tasks)."
3362 #: build/C/man2/sched_setscheduler.2:254
3364 msgid "SCHED_IDLE: Scheduling very low priority jobs"
3368 #: build/C/man2/sched_setscheduler.2:258
3370 "(Since Linux 2.6.23.) B<SCHED_IDLE> can be used only at static priority 0; "
3371 "the process nice value has no influence for this policy."
3375 #: build/C/man2/sched_setscheduler.2:266
3377 "This policy is intended for running jobs at extremely low priority (lower "
3378 "even than a +19 nice value with the B<SCHED_OTHER> or B<SCHED_BATCH> "
3383 #: build/C/man2/sched_setscheduler.2:266
3385 msgid "Resetting scheduling policy for child processes"
3389 #: build/C/man2/sched_setscheduler.2:282
3391 "Since Linux 2.6.32, the B<SCHED_RESET_ON_FORK> flag can be ORed in I<policy> "
3392 "when calling B<sched_setscheduler>(). As a result of including this flag, "
3393 "children created by B<fork>(2) do not inherit privileged scheduling "
3394 "policies. This feature is intended for media-playback applications, and can "
3395 "be used to prevent applications evading the B<RLIMIT_RTTIME> resource limit "
3396 "(see B<getrlimit>(2)) by creating multiple child processes."
3400 #: build/C/man2/sched_setscheduler.2:287
3402 "More precisely, if the B<SCHED_RESET_ON_FORK> flag is specified, the "
3403 "following rules apply for subsequently created children:"
3407 #: build/C/man2/sched_setscheduler.2:295
3409 "If the calling process has a scheduling policy of B<SCHED_FIFO> or "
3410 "B<SCHED_RR>, the policy is reset to B<SCHED_OTHER> in child processes."
3414 #: build/C/man2/sched_setscheduler.2:298
3416 "If the calling process has a negative nice value, the nice value is reset to "
3417 "zero in child processes."
3421 #: build/C/man2/sched_setscheduler.2:307
3423 "After the B<SCHED_RESET_ON_FORK> flag has been enabled, it can be reset only "
3424 "if the process has the B<CAP_SYS_NICE> capability. This flag is disabled in "
3425 "child processes created by B<fork>(2)."
3429 #: build/C/man2/sched_setscheduler.2:313
3431 "The B<SCHED_RESET_ON_FORK> flag is visible in the policy value returned by "
3432 "B<sched_getscheduler>()"
3436 #: build/C/man2/sched_setscheduler.2:313
3438 msgid "Privileges and resource limits"
3442 #: build/C/man2/sched_setscheduler.2:326
3444 "In Linux kernels before 2.6.12, only privileged (B<CAP_SYS_NICE>) processes "
3445 "can set a nonzero static priority (i.e., set a real-time scheduling "
3446 "policy). The only change that an unprivileged process can make is to set "
3447 "the B<SCHED_OTHER> policy, and this can be done only if the effective user "
3448 "ID of the caller of B<sched_setscheduler>() matches the real or effective "
3449 "user ID of the target process (i.e., the process specified by I<pid>) whose "
3450 "policy is being changed."
3454 #: build/C/man2/sched_setscheduler.2:336
3456 "Since Linux 2.6.12, the B<RLIMIT_RTPRIO> resource limit defines a ceiling on "
3457 "an unprivileged process's static priority for the B<SCHED_RR> and "
3458 "B<SCHED_FIFO> policies. The rules for changing scheduling policy and "
3459 "priority are as follows:"
3463 #: build/C/man2/sched_setscheduler.2:344
3465 "If an unprivileged process has a nonzero B<RLIMIT_RTPRIO> soft limit, then "
3466 "it can change its scheduling policy and priority, subject to the restriction "
3467 "that the priority cannot be set to a value higher than the maximum of its "
3468 "current priority and its B<RLIMIT_RTPRIO> soft limit."
3472 #: build/C/man2/sched_setscheduler.2:349
3474 "If the B<RLIMIT_RTPRIO> soft limit is 0, then the only permitted changes are "
3475 "to lower the priority, or to switch to a non-real-time policy."
3479 #: build/C/man2/sched_setscheduler.2:354
3481 "Subject to the same rules, another unprivileged process can also make these "
3482 "changes, as long as the effective user ID of the process making the change "
3483 "matches the real or effective user ID of the target process."
3486 #. commit c02aa73b1d18e43cfd79c2f193b225e84ca497c8
3488 #: build/C/man2/sched_setscheduler.2:372
3490 "Special rules apply for the B<SCHED_IDLE>. In Linux kernels before 2.6.39, "
3491 "an unprivileged process operating under this policy cannot change its "
3492 "policy, regardless of the value of its B<RLIMIT_RTPRIO> resource limit. In "
3493 "Linux kernels since 2.6.39, an unprivileged process can switch to either the "
3494 "B<SCHED_BATCH> or the B<SCHED_NORMAL> policy so long as its nice value falls "
3495 "within the range permitted by its B<RLIMIT_NICE> resource limit (see "
3500 #: build/C/man2/sched_setscheduler.2:383
3502 "Privileged (B<CAP_SYS_NICE>) processes ignore the B<RLIMIT_RTPRIO> limit; "
3503 "as with older kernels, they can make arbitrary changes to scheduling policy "
3504 "and priority. See B<getrlimit>(2) for further information on "
3509 #: build/C/man2/sched_setscheduler.2:383
3511 msgid "Response time"
3515 #. .BR request_irq (9).
3517 #: build/C/man2/sched_setscheduler.2:391
3519 "A blocked high priority process waiting for the I/O has a certain response "
3520 "time before it is scheduled again. The device driver writer can greatly "
3521 "reduce this response time by using a \"slow interrupt\" interrupt handler."
3525 #: build/C/man2/sched_setscheduler.2:391
3527 msgid "Miscellaneous"
3531 #: build/C/man2/sched_setscheduler.2:396
3533 "Child processes inherit the scheduling policy and parameters across a "
3534 "B<fork>(2). The scheduling policy and parameters are preserved across "
3539 #: build/C/man2/sched_setscheduler.2:402
3541 "Memory locking is usually needed for real-time processes to avoid paging "
3542 "delays; this can be done with B<mlock>(2) or B<mlockall>(2)."
3546 #: build/C/man2/sched_setscheduler.2:414
3548 "Since a nonblocking infinite loop in a process scheduled under B<SCHED_FIFO> "
3549 "or B<SCHED_RR> will block all processes with lower priority forever, a "
3550 "software developer should always keep available on the console a shell "
3551 "scheduled under a higher static priority than the tested application. This "
3552 "will allow an emergency kill of tested real-time applications that do not "
3553 "block or terminate as expected. See also the description of the "
3554 "B<RLIMIT_RTTIME> resource limit in B<getrlimit>(2)."
3558 #: build/C/man2/sched_setscheduler.2:422
3560 "POSIX systems on which B<sched_setscheduler>() and B<sched_getscheduler>() "
3561 "are available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3565 #: build/C/man2/sched_setscheduler.2:432
3567 "On success, B<sched_setscheduler>() returns zero. On success, "
3568 "B<sched_getscheduler>() returns the policy for the process (a nonnegative "
3569 "integer). On error, -1 is returned, and I<errno> is set appropriately."
3573 #: build/C/man2/sched_setscheduler.2:438
3575 "The scheduling I<policy> is not one of the recognized policies, I<param> is "
3576 "NULL, or I<param> does not make sense for the I<policy>."
3580 #: build/C/man2/sched_setscheduler.2:441
3581 msgid "The calling process does not have appropriate privileges."
3585 #: build/C/man2/sched_setscheduler.2:447
3587 "POSIX.1-2001 (but see BUGS below). The B<SCHED_BATCH> and B<SCHED_IDLE> "
3588 "policies are Linux-specific."
3592 #: build/C/man2/sched_setscheduler.2:455
3594 "POSIX.1 does not detail the permissions that an unprivileged process "
3595 "requires in order to call B<sched_setscheduler>(), and details vary across "
3596 "systems. For example, the Solaris 7 manual page says that the real or "
3597 "effective user ID of the calling process must match the real user ID or the "
3598 "save set-user-ID of the target process."
3602 #: build/C/man2/sched_setscheduler.2:476
3604 "The scheduling policy and parameters are in fact per-thread attributes on "
3605 "Linux. The value returned from a call to B<gettid>(2) can be passed in the "
3606 "argument I<pid>. Specifying I<pid> as 0 will operate on the attribute for "
3607 "the calling thread, and passing the value returned from a call to "
3608 "B<getpid>(2) will operate on the attribute for the main thread of the "
3609 "thread group. (If you are using the POSIX threads API, then use "
3610 "B<pthread_setschedparam>(3), B<pthread_getschedparam>(3), and "
3611 "B<pthread_setschedprio>(3), instead of the B<sched_*>(2) system calls.)"
3615 #: build/C/man2/sched_setscheduler.2:486
3617 "Originally, Standard Linux was intended as a general-purpose operating "
3618 "system being able to handle background processes, interactive applications, "
3619 "and less demanding real-time applications (applications that need to usually "
3620 "meet timing deadlines). Although the Linux kernel 2.6 allowed for kernel "
3621 "preemption and the newly introduced O(1) scheduler ensures that the time "
3622 "needed to schedule is fixed and deterministic irrespective of the number of "
3623 "active tasks, true real-time computing was not possible up to kernel version "
3628 #: build/C/man2/sched_setscheduler.2:486
3630 msgid "Real-time features in the mainline Linux kernel"
3633 #. FIXME . Probably this text will need some minor tweaking
3634 #. by about the time of 2.6.30; ask Carsten Emde about this then.
3636 #: build/C/man2/sched_setscheduler.2:500
3638 "From kernel version 2.6.18 onward, however, Linux is gradually becoming "
3639 "equipped with real-time capabilities, most of which are derived from the "
3640 "former I<realtime-preempt> patches developed by Ingo Molnar, Thomas "
3641 "Gleixner, Steven Rostedt, and others. Until the patches have been "
3642 "completely merged into the mainline kernel (this is expected to be around "
3643 "kernel version 2.6.30), they must be installed to achieve the best real-time "
3644 "performance. These patches are named:"
3648 #: build/C/man2/sched_setscheduler.2:504
3650 msgid "patch-I<kernelversion>-rtI<patchversion>\n"
3654 #: build/C/man2/sched_setscheduler.2:510
3656 "and can be downloaded from E<.UR "
3657 "http://www.kernel.org\\:/pub\\:/linux\\:/kernel\\:/projects\\:/rt/> E<.UE .>"
3661 #: build/C/man2/sched_setscheduler.2:519
3663 "Without the patches and prior to their full inclusion into the mainline "
3664 "kernel, the kernel configuration offers only the three preemption classes "
3665 "B<CONFIG_PREEMPT_NONE>, B<CONFIG_PREEMPT_VOLUNTARY>, and "
3666 "B<CONFIG_PREEMPT_DESKTOP> which respectively provide no, some, and "
3667 "considerable reduction of the worst-case scheduling latency."
3671 #: build/C/man2/sched_setscheduler.2:530
3673 "With the patches applied or after their full inclusion into the mainline "
3674 "kernel, the additional configuration item B<CONFIG_PREEMPT_RT> becomes "
3675 "available. If this is selected, Linux is transformed into a regular "
3676 "real-time operating system. The FIFO and RR scheduling policies that can be "
3677 "selected using B<sched_setscheduler>() are then used to run a process with "
3678 "true real-time priority and a minimum worst-case scheduling latency."
3682 #: build/C/man2/sched_setscheduler.2:538
3684 "POSIX says that on success, B<sched_setscheduler>() should return the "
3685 "previous scheduling policy. Linux B<sched_setscheduler>() does not conform "
3686 "to this requirement, since it always returns 0 on success."
3690 #: build/C/man2/sched_setscheduler.2:559
3692 "B<chrt>(1), B<getpriority>(2), B<mlock>(2), B<mlockall>(2), B<munlock>(2), "
3693 "B<munlockall>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3694 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), B<sched_getparam>(2), "
3695 "B<sched_rr_get_interval>(2), B<sched_setaffinity>(2), B<sched_setparam>(2), "
3696 "B<sched_yield>(2), B<setpriority>(2), B<capabilities>(7), B<cpuset>(7)"
3700 #: build/C/man2/sched_setscheduler.2:566
3701 msgid "The Linux kernel source file I<Documentation/scheduler/sched-rt-group.txt>"
3705 #: build/C/man2/sched_yield.2:29
3711 #: build/C/man2/sched_yield.2:29
3717 #: build/C/man2/sched_yield.2:32
3718 msgid "sched_yield - yield the processor"
3722 #: build/C/man2/sched_yield.2:36
3723 msgid "B<int sched_yield(void);>"
3727 #: build/C/man2/sched_yield.2:41
3729 "B<sched_yield>() causes the calling thread to relinquish the CPU. The "
3730 "thread is moved to the end of the queue for its static priority and a new "
3731 "thread gets to run."
3735 #: build/C/man2/sched_yield.2:48
3737 "On success, B<sched_yield>() returns 0. On error, -1 is returned, and "
3738 "I<errno> is set appropriately."
3742 #: build/C/man2/sched_yield.2:52
3743 msgid "In the Linux implementation, B<sched_yield>() always succeeds."
3747 #: build/C/man2/sched_yield.2:59
3749 "If the calling thread is the only thread in the highest priority list at "
3750 "that time, it will continue to run after a call to B<sched_yield>()."
3754 #: build/C/man2/sched_yield.2:66
3756 "POSIX systems on which B<sched_yield>() is available define "
3757 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3761 #: build/C/man2/sched_yield.2:79
3763 "Strategic calls to B<sched_yield>() can improve performance by giving other "
3764 "threads or processes a chance to run when (heavily) contended resources "
3765 "(e.g., mutexes) have been released by the caller. Avoid calling "
3766 "B<sched_yield>() unnecessarily or inappropriately (e.g., when resources "
3767 "needed by other schedulable threads are still held by the caller), since "
3768 "doing so will result in unnecessary context switches, which will degrade "
3769 "system performance."
3773 #: build/C/man2/sched_yield.2:82
3774 msgid "B<sched_setscheduler>(2) for a description of Linux scheduling"
3778 #: build/C/man2/setns.2:8
3784 #: build/C/man2/setns.2:8
3790 #: build/C/man2/setns.2:11
3791 msgid "setns - reassociate thread with a namespace"
3795 #: build/C/man2/setns.2:17
3797 msgid "B<int setns(int >I<fd>B<, int >I<nstype>B<);>\n"
3801 #: build/C/man2/setns.2:21
3803 "Given a file descriptor referring to a namespace, reassociate the calling "
3804 "thread with that namespace."
3808 #: build/C/man2/setns.2:34
3810 "The I<fd> argument is a file descriptor referring to one of the namespace "
3811 "entries in a I</proc/[pid]/ns/> directory; see B<proc>(5) for further "
3812 "information on I</proc/[pid]/ns/>. The calling thread will be reassociated "
3813 "with the corresponding namespace, subject to any constraints imposed by the "
3814 "I<nstype> argument."
3818 #: build/C/man2/setns.2:40
3820 "The I<nstype> argument specifies which type of namespace the calling thread "
3821 "may be reassociated with. This argument can have one of the following "
3826 #: build/C/man2/setns.2:40
3832 #: build/C/man2/setns.2:43
3833 msgid "Allow any type of namespace to be joined."
3837 #: build/C/man2/setns.2:43
3839 msgid "B<CLONE_NEWIPC>"
3843 #: build/C/man2/setns.2:47
3844 msgid "I<fd> must refer to an IPC namespace."
3848 #: build/C/man2/setns.2:47
3850 msgid "B<CLONE_NEWNET>"
3854 #: build/C/man2/setns.2:51
3855 msgid "I<fd> must refer to a network namespace."
3859 #: build/C/man2/setns.2:51
3861 msgid "B<CLONE_NEWUTS>"
3865 #: build/C/man2/setns.2:55
3866 msgid "I<fd> must refer to a UTS namespace."
3870 #: build/C/man2/setns.2:70
3872 "Specifying I<nstype> as 0 suffices if the caller knows (or does not care) "
3873 "what type of namespace is referred to by I<fd>. Specifying a nonzero value "
3874 "for I<nstype> is useful if the caller does not know what type of namespace "
3875 "is referred to by I<fd> and wants to ensure that the namespace is of a "
3876 "particular type. (The caller might not know the type of the namespace "
3877 "referred to by I<fd> if the file descriptor was opened by another process "
3878 "and, for example, passed to the caller via a UNIX domain socket.)"
3882 #: build/C/man2/setns.2:77
3884 "On success, I<setns>() returns 0. On failure, -1 is returned and I<errno> "
3885 "is set to indicate the error."
3889 #: build/C/man2/setns.2:82
3890 msgid "I<fd> is not a valid file descriptor."
3894 #: build/C/man2/setns.2:89
3896 "I<fd> refers to a namespace whose type does not match that specified in "
3897 "I<nstype>, or there is problem with reassociating the the thread with the "
3898 "specified namespace."
3902 #: build/C/man2/setns.2:92
3903 msgid "Cannot allocate sufficient memory to change the specified namespace."
3907 #: build/C/man2/setns.2:97
3909 "The calling thread did not have the required privilege (B<CAP_SYS_ADMIN>) "
3910 "for this operation."
3914 #: build/C/man2/setns.2:102
3916 "The B<setns>() system call first appeared in Linux in kernel 3.0; library "
3917 "support was added to glibc in version 2.14."
3921 #: build/C/man2/setns.2:106
3922 msgid "The B<setns>() system call is Linux-specific."
3926 #: build/C/man2/setns.2:112
3928 "Not all of the attributes that can be shared when a new thread is created "
3929 "using B<clone>(2) can be changed using B<setns>()."
3933 #: build/C/man2/setns.2:121
3935 "The program below takes two or more arguments. The first argument specifies "
3936 "the pathname of a namespace file in an existing I</proc/[pid]/ns/> "
3937 "directory. The remaining arguments specify a command and its arguments. "
3938 "The program opens the namespace file, joins that namespace using B<setns>(), "
3939 "and executes the specified command inside that namespace."
3943 #: build/C/man2/setns.2:131
3945 "The following shell session demonstrates the use of this program (compiled "
3946 "as a binary named I<ns_exec>) in conjunction with the B<CLONE_NEWUTS> "
3947 "example program in the B<clone>(2) man page (complied as a binary named "
3952 #: build/C/man2/setns.2:139
3954 "We begin by executing the example program in B<clone>(2) in the "
3955 "background. That program creates a child in a separate UTS namespace. The "
3956 "child changes the hostname in its namespace, and then both processes display "
3957 "the hostnames in their UTS namespaces, so that we can see that they are "
3962 #: build/C/man2/setns.2:151
3965 "$ B<su> # Need privilege for namespace operations\n"
3967 "# B<./newuts bizarro &>\n"
3969 "clone() returned 3550\n"
3970 "uts.nodename in child: bizarro\n"
3971 "uts.nodename in parent: antero\n"
3972 "# B<uname -n> # Verify hostname in the shell\n"
3977 #: build/C/man2/setns.2:158
3979 "We then run the program shown below, using it to execute a shell. Inside "
3980 "that shell, we verify that the hostname is the one set by the child created "
3981 "by the first program:"
3985 #: build/C/man2/setns.2:164
3988 "# B<./ns_exec /proc/3550/ns/uts /bin/bash>\n"
3989 "# B<uname -n> # Executed in shell started by ns_exec\n"
3994 #: build/C/man2/setns.2:166
3996 msgid "Program source"
4000 #: build/C/man2/setns.2:174
4003 "#define _GNU_SOURCE\n"
4004 "#include E<lt>fcntl.hE<gt>\n"
4005 "#include E<lt>sched.hE<gt>\n"
4006 "#include E<lt>unistd.hE<gt>\n"
4007 "#include E<lt>stdlib.hE<gt>\n"
4008 "#include E<lt>stdio.hE<gt>\n"
4012 #: build/C/man2/setns.2:182
4016 "main(int argc, char *argv[])\n"
4022 #: build/C/man2/setns.2:187
4025 " if (argc E<lt> 3) {\n"
4026 " fprintf(stderr, \"%s /proc/PID/ns/FILE cmd args...\\en\", "
4028 " exit(EXIT_FAILURE);\n"
4033 #: build/C/man2/setns.2:191
4036 " fd = open(argv[1], O_RDONLY); /* Get descriptor for namespace */\n"
4038 " errExit(\"open\");\n"
4042 #: build/C/man2/setns.2:194
4045 " if (setns(fd, 0) == -1) /* Join that namespace */\n"
4046 " errExit(\"setns\");\n"
4050 #: build/C/man2/setns.2:198
4053 " execvp(argv[2], &argv[2]); /* Execute a command in namespace */\n"
4054 " errExit(\"execvp\");\n"
4059 #: build/C/man2/setns.2:205
4060 msgid "B<clone>(2), B<fork>(2), B<vfork>(2), B<proc>(5), B<unix>(7)"
4064 #: build/C/man2/unshare.2:20
4070 #: build/C/man2/unshare.2:23
4071 msgid "unshare - disassociate parts of the process execution context"
4075 #: build/C/man2/unshare.2:28
4077 msgid "B<int unshare(int >I<flags>B<);>\n"
4081 #: build/C/man2/unshare.2:36
4082 msgid "B<unshare>():"
4086 #: build/C/man2/unshare.2:62
4088 "B<unshare>() allows a process to disassociate parts of its execution "
4089 "context that are currently being shared with other processes. Part of the "
4090 "execution context, such as the mount namespace, is shared implicitly when a "
4091 "new process is created using B<fork>(2) or B<vfork>(2), while other parts, "
4092 "such as virtual memory, may be shared by explicit request when creating a "
4093 "process using B<clone>(2)."
4097 #: build/C/man2/unshare.2:67
4099 "The main use of B<unshare>() is to allow a process to control its shared "
4100 "execution context without creating a new process."
4104 #: build/C/man2/unshare.2:74
4106 "The I<flags> argument is a bit mask that specifies which parts of the "
4107 "execution context should be unshared. This argument is specified by ORing "
4108 "together zero or more of the following constants:"
4112 #: build/C/man2/unshare.2:74
4114 msgid "B<CLONE_FILES>"
4118 #: build/C/man2/unshare.2:82
4120 "Reverse the effect of the B<clone>(2) B<CLONE_FILES> flag. Unshare the "
4121 "file descriptor table, so that the calling process no longer shares its file "
4122 "descriptors with any other process."
4126 #: build/C/man2/unshare.2:82
4132 #: build/C/man2/unshare.2:96
4134 "Reverse the effect of the B<clone>(2) B<CLONE_FS> flag. Unshare file "
4135 "system attributes, so that the calling process no longer shares its root "
4136 "directory (B<chroot>(2)), current directory (B<chdir>(2)), or umask "
4137 "(B<umask>(2)) attributes with any other process."
4141 #: build/C/man2/unshare.2:113
4143 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWIPC> flag. "
4144 "Unshare the System V IPC namespace, so that the calling process has a "
4145 "private copy of the System V IPC namespace which is not shared with any "
4146 "other process. Specifying this flag automatically implies B<CLONE_SYSVSEM> "
4147 "as well. Use of B<CLONE_NEWIPC> requires the B<CAP_SYS_ADMIN> capability."
4151 #: build/C/man2/unshare.2:128
4153 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNET> flag. "
4154 "Unshare the network namespace, so that the calling process is moved into a "
4155 "new network namespace which is not shared with any previously existing "
4156 "process. Use of B<CLONE_NEWNET> requires the B<CAP_SYS_ADMIN> capability."
4160 #: build/C/man2/unshare.2:128
4162 msgid "B<CLONE_NEWNS>"
4165 #. These flag name are inconsistent:
4166 #. CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
4167 #. CLONE_FS, and CLONE_FILES reverse the action of the clone()
4168 #. flags of the same name.
4170 #: build/C/man2/unshare.2:149
4172 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNS> flag. "
4173 "Unshare the mount namespace, so that the calling process has a private copy "
4174 "of its namespace which is not shared with any other process. Specifying "
4175 "this flag automatically implies B<CLONE_FS> as well. Use of B<CLONE_NEWNS> "
4176 "requires the B<CAP_SYS_ADMIN> capability."
4180 #: build/C/man2/unshare.2:163
4182 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWUTS> flag. "
4183 "Unshare the UTS IPC namespace, so that the calling process has a private "
4184 "copy of the UTS namespace which is not shared with any other process. Use "
4185 "of B<CLONE_NEWUTS> requires the B<CAP_SYS_ADMIN> capability."
4189 #: build/C/man2/unshare.2:163
4191 msgid "B<CLONE_SYSVSEM> (since Linux 2.6.26)"
4194 #. commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
4195 #. As at 2.6.16, the following forced implications also apply,
4196 #. although the relevant flags are not yet implemented.
4197 #. If CLONE_THREAD is set force CLONE_VM.
4198 #. If CLONE_VM is set, force CLONE_SIGHAND.
4199 #. CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
4200 #. (i.e., current->signal->count > 1), force CLONE_THREAD.
4202 #. FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
4205 #. Reverse the effect of the
4210 #. is also implicitly set by
4212 #. and can be reversed using this
4215 #. Unshare virtual memory, so that the calling process no
4216 #. longer shares its virtual address space with any other process.
4218 #: build/C/man2/unshare.2:200
4220 "This flag reverses the effect of the B<clone>(2) B<CLONE_SYSVSEM> flag. "
4221 "Unshare System V semaphore undo values, so that the calling process has a "
4222 "private copy which is not shared with any other process. Use of "
4223 "B<CLONE_SYSVSEM> requires the B<CAP_SYS_ADMIN> capability."
4227 #: build/C/man2/unshare.2:207
4229 "If I<flags> is specified as zero, then B<unshare>() is a no-op; no changes "
4230 "are made to the calling process's execution context."
4234 #: build/C/man2/unshare.2:212
4236 "On success, zero returned. On failure, -1 is returned and I<errno> is set "
4237 "to indicate the error."
4241 #: build/C/man2/unshare.2:217
4242 msgid "An invalid bit was specified in I<flags>."
4246 #: build/C/man2/unshare.2:221
4248 "Cannot allocate sufficient memory to copy parts of caller's context that "
4249 "need to be unshared."
4253 #: build/C/man2/unshare.2:224
4254 msgid "The calling process did not have the required privileges for this operation."
4258 #: build/C/man2/unshare.2:228
4259 msgid "The B<unshare>() system call was added to Linux in kernel 2.6.16."
4263 #: build/C/man2/unshare.2:232
4264 msgid "The B<unshare>() system call is Linux-specific."
4267 #. FIXME all of the following needs to be reviewed for the current kernel
4268 #. However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
4269 #. was not specified when doing clone(); i.e., unsharing
4270 #. signal handlers is permitted if we are not actually
4271 #. sharing signal handlers. mtk
4272 #. However, we can do unshare(CLONE_VM) if CLONE_VM
4273 #. was not specified when doing clone(); i.e., unsharing
4274 #. virtual memory is permitted if we are not actually
4275 #. sharing virtual memory. mtk
4279 #. The current implementation of unshare does not allow unsharing of
4280 #. signals and signal handlers. Signals are complex to begin with and
4281 #. to unshare signals and/or signal handlers of a currently running
4282 #. process is even more complex. If in the future there is a specific
4283 #. need to allow unsharing of signals and/or signal handlers, it can
4284 #. be incrementally added to unshare without affecting legacy
4285 #. applications using unshare.
4287 #: build/C/man2/unshare.2:266
4289 "Not all of the process attributes that can be shared when a new process is "
4290 "created using B<clone>(2) can be unshared using B<unshare>(). In "
4291 "particular, as at kernel 3.8, B<unshare>() does not implement flags that "
4292 "reverse the effects of B<CLONE_SIGHAND>, B<CLONE_THREAD>, or B<CLONE_VM>. "
4293 "Such functionality may be added in the future, if required."
4297 #: build/C/man2/unshare.2:272
4298 msgid "B<clone>(2), B<fork>(2), B<kcmp>(2), B<setns>(2), B<vfork>(2)"
4302 #: build/C/man2/unshare.2:275
4303 msgid "I<Documentation/unshare.txt> in the Linux kernel source tree"