# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2024-06-01 06:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "pthread_create" msgstr "" #. type: TH #: archlinux debian-unstable opensuse-tumbleweed #, no-wrap msgid "2024-05-02" msgstr "" #. type: TH #: archlinux debian-unstable #, no-wrap msgid "Linux man-pages 6.8" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "pthread_create - create a new thread" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "LIBRARY" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "POSIX threads library (I, I<-lpthread>)" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B<#include Epthread.hE>\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "BIB<,>\n" "B< const pthread_attr_t *restrict >IB<,>\n" "B< void *(*>IB<)(void *),>\n" "B< void *restrict >IB<);>\n" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function starts a new thread in the calling " "process. The new thread starts execution by invoking I(); " "I is passed as the sole argument of I()." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The new thread terminates in one of the following ways:" msgstr "" #. type: IP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "\\[bu]" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "It calls B(3), specifying an exit status value that is " "available to another thread in the same process that calls " "B(3)." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "It returns from I(). This is equivalent to calling " "B(3) with the value supplied in the I statement." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "It is canceled (see B(3))." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "Any of the threads in the process calls B(3), or the main thread " "performs a return from I
(). This causes the termination of all " "threads in the process." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The I argument points to a I structure whose contents " "are used at thread creation time to determine attributes for the new thread; " "this structure is initialized using B(3) and related " "functions. If I is NULL, then the thread is created with default " "attributes." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "Before returning, a successful call to B() stores the ID of " "the new thread in the buffer pointed to by I; this identifier is " "used to refer to the thread in subsequent calls to other pthreads functions." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The new thread inherits a copy of the creating thread's signal mask " "(B(3)). The set of pending signals for the new thread is " "empty (B(2)). The new thread does not inherit the creating " "thread's alternate signal stack (B(2))." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The new thread inherits the calling thread's floating-point environment " "(B(3))." msgstr "" #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2) #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The initial value of the new thread's CPU-time clock is 0 (see " "B(3))." msgstr "" #. type: SS #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Linux-specific details" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The new thread inherits copies of the calling thread's capability sets (see " "B(7)) and CPU affinity mask (see B(2))." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "RETURN VALUE" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "On success, B() returns 0; on error, it returns an error " "number, and the contents of I<*thread> are undefined." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "ERRORS" msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Insufficient resources to create another thread." msgstr "" #. NOTE! The following should match the description in fork(2) #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "A system-imposed limit on the number of threads was encountered. There are " "a number of limits that may trigger this error: the B soft " "resource limit (set via B(2)), which limits the number of " "processes and threads for a real user ID, was reached; the kernel's system-" "wide limit on the number of processes and threads, I, was reached (see B(5)); or the maximum number of PIDs, " "I, was reached (see B(5))." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Invalid settings in I." msgstr "" #. FIXME . Test the following #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "No permission to set the scheduling policy and parameters specified in " "I." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "ATTRIBUTES" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "For an explanation of the terms used in this section, see B(7)." msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Interface" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Attribute" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Value" msgstr "" #. type: tbl table #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid ".na\n" msgstr "" #. type: tbl table #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid ".nh\n" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B()" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Thread safety" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "MT-Safe" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "STANDARDS" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed msgid "POSIX.1-2008." msgstr "" #. type: SH #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "HISTORY" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed msgid "POSIX.1-2001." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "See B(3) for further information on the thread ID returned in " "I<*thread> by B(). Unless real-time scheduling policies are " "being employed, after a call to B(), it is indeterminate " "which thread\\[em]the caller or the new thread\\[em]will next execute." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "A thread may either be I or I. If a thread is joinable, " "then another thread can call B(3) to wait for the thread to " "terminate and fetch its exit status. Only when a terminated joinable thread " "has been joined are the last of its resources released back to the system. " "When a detached thread terminates, its resources are automatically released " "back to the system: it is not possible to join with the thread in order to " "obtain its exit status. Making a thread detached is useful for some types " "of daemon threads whose exit status the application does not need to care " "about. By default, a new thread is created in a joinable state, unless " "I was set to create the thread in a detached state (using " "B(3))." msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed msgid "" "Under the NPTL threading implementation, if the B soft " "resource limit I has any value other than " "\"unlimited\", then it determines the default stack size of new threads. " "Using B(3), the stack size attribute can be " "explicitly set in the I argument used to create a thread, in order to " "obtain a stack size other than the default. If the B resource " "limit is set to \"unlimited\", a per-architecture value is used for the " "stack size: 2 MB on most architectures; 4 MB on POWER and Sparc-64." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "BUGS" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "In the obsolete LinuxThreads implementation, each of the threads in a " "process has a different process ID. This is in violation of the POSIX " "threads specification, and is the source of many other nonconformances to " "the standard; see B(7)." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "EXAMPLES" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The program below demonstrates the use of B(), as well as a " "number of other functions in the pthreads API." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "In the following run, on a system providing the NPTL threading " "implementation, the stack size defaults to the value given by the \"stack " "size\" resource limit:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "$B< ulimit -s>\n" "8192 # The stack size limit is 8 MB (0x800000 bytes)\n" "$B< ./a.out hola salut servus>\n" "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n" "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n" "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n" "Joined with thread 1; returned value was HOLA\n" "Joined with thread 2; returned value was SALUT\n" "Joined with thread 3; returned value was SERVUS\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "In the next run, the program explicitly sets a stack size of 1\\ MB (using " "B(3)) for the created threads:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "$B< ./a.out -s 0x100000 hola salut servus>\n" "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n" "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n" "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n" "Joined with thread 1; returned value was HOLA\n" "Joined with thread 2; returned value was SALUT\n" "Joined with thread 3; returned value was SERVUS\n" msgstr "" #. type: SS #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Program source" msgstr "" #. type: Plain text #: archlinux debian-unstable opensuse-tumbleweed #, no-wrap msgid "" "#include Ectype.hE\n" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Esys/types.hE\n" "#include Eunistd.hE\n" "\\&\n" "#define handle_error_en(en, msg) \\e\n" " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "#define handle_error(msg) \\e\n" " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "struct thread_info { /* Used as argument to thread_start() */\n" " pthread_t thread_id; /* ID returned by pthread_create() */\n" " int thread_num; /* Application-defined thread # */\n" " char *argv_string; /* From command-line argument */\n" "};\n" "\\&\n" "/* Thread start function: display address near top of our stack,\n" " and return upper-cased copy of argv_string. */\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " struct thread_info *tinfo = arg;\n" " char *uargv;\n" "\\&\n" " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n" " tinfo-Ethread_num, (void *) &tinfo, tinfo-Eargv_string);\n" "\\&\n" " uargv = strdup(tinfo-Eargv_string);\n" " if (uargv == NULL)\n" " handle_error(\"strdup\");\n" "\\&\n" " for (char *p = uargv; *p != \\[aq]\\e0\\[aq]; p++)\n" " *p = toupper(*p);\n" "\\&\n" " return uargv;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s, opt;\n" " void *res;\n" " size_t num_threads;\n" " ssize_t stack_size;\n" " pthread_attr_t attr;\n" " struct thread_info *tinfo;\n" "\\&\n" " /* The \"-s\" option specifies a stack size for our threads. */\n" "\\&\n" " stack_size = -1;\n" " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n" " switch (opt) {\n" " case \\[aq]s\\[aq]:\n" " stack_size = strtoul(optarg, NULL, 0);\n" " break;\n" "\\&\n" " default:\n" " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n" " argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" " }\n" "\\&\n" " num_threads = argc - optind;\n" "\\&\n" " /* Initialize thread creation attributes. */\n" "\\&\n" " s = pthread_attr_init(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_init\");\n" "\\&\n" " if (stack_size E 0) {\n" " s = pthread_attr_setstacksize(&attr, stack_size);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_setstacksize\");\n" " }\n" "\\&\n" " /* Allocate memory for pthread_create() arguments. */\n" "\\&\n" " tinfo = calloc(num_threads, sizeof(*tinfo));\n" " if (tinfo == NULL)\n" " handle_error(\"calloc\");\n" "\\&\n" " /* Create one thread for each command-line argument. */\n" "\\&\n" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " tinfo[tnum].thread_num = tnum + 1;\n" " tinfo[tnum].argv_string = argv[optind + tnum];\n" "\\&\n" " /* The pthread_create() call stores the thread ID into\n" " corresponding element of tinfo[]. */\n" "\\&\n" " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n" " &thread_start, &tinfo[tnum]);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Destroy the thread attributes object, since it is no\n" " longer needed. */\n" "\\&\n" " s = pthread_attr_destroy(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_destroy\");\n" "\\&\n" " /* Now join with each thread, and display its returned value. */\n" "\\&\n" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " s = pthread_join(tinfo[tnum].thread_id, &res);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_join\");\n" "\\&\n" " printf(\"Joined with thread %d; returned value was %s\\en\",\n" " tinfo[tnum].thread_num, (char *) res);\n" " free(res); /* Free memory allocated by thread */\n" " }\n" "\\&\n" " free(tinfo);\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. SRC END #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "B(2), B(3), B(3), " "B(3), B(3), B(3), " "B(3), B(3), B(3), " "B(3), B(7)" msgstr "" #. type: TH #: debian-bookworm #, no-wrap msgid "2023-02-05" msgstr "" #. type: TH #: debian-bookworm #, no-wrap msgid "Linux man-pages 6.03" msgstr "" #. type: Plain text #: debian-bookworm msgid "POSIX.1-2001, POSIX.1-2008." msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 msgid "" "Under the NPTL threading implementation, if the B soft " "resource limit I has any value other than " "\"unlimited\", then it determines the default stack size of new threads. " "Using B(3), the stack size attribute can be " "explicitly set in the I argument used to create a thread, in order to " "obtain a stack size other than the default. If the B resource " "limit is set to \"unlimited\", a per-architecture value is used for the " "stack size. Here is the value for a few architectures:" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "Architecture" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "Default stack size" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "i386" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "2 MB" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "IA-64" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "32 MB" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "PowerPC" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "4 MB" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "S/390" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "Sparc-32" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "Sparc-64" msgstr "" #. type: tbl table #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "x86_64" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "#include Ectype.hE\n" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Eunistd.hE\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "#define handle_error_en(en, msg) \\e\n" " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "#define handle_error(msg) \\e\n" " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "struct thread_info { /* Used as argument to thread_start() */\n" " pthread_t thread_id; /* ID returned by pthread_create() */\n" " int thread_num; /* Application-defined thread # */\n" " char *argv_string; /* From command-line argument */\n" "};\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "/* Thread start function: display address near top of our stack,\n" " and return upper-cased copy of argv_string. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "static void *\n" "thread_start(void *arg)\n" "{\n" " struct thread_info *tinfo = arg;\n" " char *uargv;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n" " tinfo-Ethread_num, (void *) &tinfo, tinfo-Eargv_string);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " uargv = strdup(tinfo-Eargv_string);\n" " if (uargv == NULL)\n" " handle_error(\"strdup\");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (char *p = uargv; *p != \\[aq]\\e0\\[aq]; p++)\n" " *p = toupper(*p);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " return uargv;\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s, opt;\n" " void *res;\n" " size_t num_threads;\n" " ssize_t stack_size;\n" " pthread_attr_t attr;\n" " struct thread_info *tinfo;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* The \"-s\" option specifies a stack size for our threads. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " stack_size = -1;\n" " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n" " switch (opt) {\n" " case \\[aq]s\\[aq]:\n" " stack_size = strtoul(optarg, NULL, 0);\n" " break;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " default:\n" " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n" " argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " num_threads = argc - optind;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* Initialize thread creation attributes. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " s = pthread_attr_init(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_init\");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (stack_size E 0) {\n" " s = pthread_attr_setstacksize(&attr, stack_size);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_setstacksize\");\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* Allocate memory for pthread_create() arguments. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " tinfo = calloc(num_threads, sizeof(*tinfo));\n" " if (tinfo == NULL)\n" " handle_error(\"calloc\");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* Create one thread for each command-line argument. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " tinfo[tnum].thread_num = tnum + 1;\n" " tinfo[tnum].argv_string = argv[optind + tnum];\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " /* The pthread_create() call stores the thread ID into\n" " corresponding element of tinfo[]. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n" " &thread_start, &tinfo[tnum]);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_create\");\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " /* Destroy the thread attributes object, since it is no\n" " longer needed. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " s = pthread_attr_destroy(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_destroy\");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* Now join with each thread, and display its returned value. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " s = pthread_join(tinfo[tnum].thread_id, &res);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_join\");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " printf(\"Joined with thread %d; returned value was %s\\en\",\n" " tinfo[tnum].thread_num, (char *) res);\n" " free(res); /* Free memory allocated by thread */\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " free(tinfo);\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: TH #: fedora-40 fedora-rawhide mageia-cauldron #, no-wrap msgid "2024-02-12" msgstr "" #. type: TH #: fedora-40 mageia-cauldron #, no-wrap msgid "Linux man-pages 6.06" msgstr "" #. type: Plain text #: fedora-40 fedora-rawhide mageia-cauldron #, no-wrap msgid "" "#include Ectype.hE\n" "#include Eerrno.hE\n" "#include Epthread.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "#include Eunistd.hE\n" "\\&\n" "#define handle_error_en(en, msg) \\e\n" " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "#define handle_error(msg) \\e\n" " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n" "\\&\n" "struct thread_info { /* Used as argument to thread_start() */\n" " pthread_t thread_id; /* ID returned by pthread_create() */\n" " int thread_num; /* Application-defined thread # */\n" " char *argv_string; /* From command-line argument */\n" "};\n" "\\&\n" "/* Thread start function: display address near top of our stack,\n" " and return upper-cased copy of argv_string. */\n" "\\&\n" "static void *\n" "thread_start(void *arg)\n" "{\n" " struct thread_info *tinfo = arg;\n" " char *uargv;\n" "\\&\n" " printf(\"Thread %d: top of stack near %p; argv_string=%s\\en\",\n" " tinfo-Ethread_num, (void *) &tinfo, tinfo-Eargv_string);\n" "\\&\n" " uargv = strdup(tinfo-Eargv_string);\n" " if (uargv == NULL)\n" " handle_error(\"strdup\");\n" "\\&\n" " for (char *p = uargv; *p != \\[aq]\\e0\\[aq]; p++)\n" " *p = toupper(*p);\n" "\\&\n" " return uargv;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int s, opt;\n" " void *res;\n" " size_t num_threads;\n" " ssize_t stack_size;\n" " pthread_attr_t attr;\n" " struct thread_info *tinfo;\n" "\\&\n" " /* The \"-s\" option specifies a stack size for our threads. */\n" "\\&\n" " stack_size = -1;\n" " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n" " switch (opt) {\n" " case \\[aq]s\\[aq]:\n" " stack_size = strtoul(optarg, NULL, 0);\n" " break;\n" "\\&\n" " default:\n" " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\en\",\n" " argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" " }\n" "\\&\n" " num_threads = argc - optind;\n" "\\&\n" " /* Initialize thread creation attributes. */\n" "\\&\n" " s = pthread_attr_init(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_init\");\n" "\\&\n" " if (stack_size E 0) {\n" " s = pthread_attr_setstacksize(&attr, stack_size);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_setstacksize\");\n" " }\n" "\\&\n" " /* Allocate memory for pthread_create() arguments. */\n" "\\&\n" " tinfo = calloc(num_threads, sizeof(*tinfo));\n" " if (tinfo == NULL)\n" " handle_error(\"calloc\");\n" "\\&\n" " /* Create one thread for each command-line argument. */\n" "\\&\n" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " tinfo[tnum].thread_num = tnum + 1;\n" " tinfo[tnum].argv_string = argv[optind + tnum];\n" "\\&\n" " /* The pthread_create() call stores the thread ID into\n" " corresponding element of tinfo[]. */\n" "\\&\n" " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n" " &thread_start, &tinfo[tnum]);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_create\");\n" " }\n" "\\&\n" " /* Destroy the thread attributes object, since it is no\n" " longer needed. */\n" "\\&\n" " s = pthread_attr_destroy(&attr);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_attr_destroy\");\n" "\\&\n" " /* Now join with each thread, and display its returned value. */\n" "\\&\n" " for (size_t tnum = 0; tnum E num_threads; tnum++) {\n" " s = pthread_join(tinfo[tnum].thread_id, &res);\n" " if (s != 0)\n" " handle_error_en(s, \"pthread_join\");\n" "\\&\n" " printf(\"Joined with thread %d; returned value was %s\\en\",\n" " tinfo[tnum].thread_num, (char *) res);\n" " free(res); /* Free memory allocated by thread */\n" " }\n" "\\&\n" " free(tinfo);\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: TH #: fedora-rawhide #, no-wrap msgid "Linux man-pages 6.7" msgstr "" #. type: TH #: opensuse-leap-15-6 #, no-wrap msgid "2023-03-30" msgstr "" #. type: TH #: opensuse-leap-15-6 #, no-wrap msgid "Linux man-pages 6.04" msgstr "" #. type: TH #: opensuse-tumbleweed #, no-wrap msgid "Linux man-pages (unreleased)" msgstr ""