Debian Codegraph @

po/ar/man3/pthread_create.3.po

raw
1 # Arabic translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # زايد السعيدي <[email protected]>, 2026.
5 msgid ""
6 msgstr ""
7 "Project-Id-Version: manpages-l10n 4.30.2\n"
8 "POT-Creation-Date: 2026-06-05 06:38+0200\n"
9 "PO-Revision-Date: 2026-06-02 19:37+0400\n"
10 "Last-Translator: Zayed Al-Saidi <[email protected]>\n"
11 "Language-Team: Arabic <[email protected]>\n"
12 "Language: ar\n"
13 "MIME-Version: 1.0\n"
14 "Content-Type: text/plain; charset=UTF-8\n"
15 "Content-Transfer-Encoding: 8bit\n"
16 "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
17 "&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
18 "X-Generator: Lokalize 23.08.5\n"
19
20 #. type: TH
21 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
22 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
23 #, no-wrap
24 msgid "pthread_create"
25 msgstr "pthread_create"
26
27 #. type: TH
28 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
29 #: opensuse-tumbleweed
30 #, no-wrap
31 msgid "2026-02-10"
32 msgstr "10 فبراير 2026"
33
34 #. type: TH
35 #: archlinux debian-unstable
36 #, no-wrap
37 msgid "Linux man-pages 6.18"
38 msgstr "صفحات دليل لينكس 6.18"
39
40 #. type: SH
41 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
42 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
43 #, no-wrap
44 msgid "NAME"
45 msgstr "الاسم"
46
47 #. type: Plain text
48 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
49 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
50 msgid "pthread_create - create a new thread"
51 msgstr "pthread_create - إنشاء خيط جديد"
52
53 #. type: SH
54 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
55 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
56 #, no-wrap
57 msgid "LIBRARY"
58 msgstr "المكتبة"
59
60 #. type: Plain text
61 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
62 #: opensuse-leap-16-1 opensuse-tumbleweed
63 msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)"
64 msgstr "مكتبة مسالك POSIX (I<libpthread>،\\ I<-lpthread>)"
65
66 #. type: SH
67 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
68 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
69 #, no-wrap
70 msgid "SYNOPSIS"
71 msgstr "موجز"
72
73 #. type: Plain text
74 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
75 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
76 #, no-wrap
77 msgid "B<#include E<lt>pthread.hE<gt>>\n"
78 msgstr "B<#include E<lt>pthread.hE<gt>>\n"
79
80 #. type: Plain text
81 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
82 #: opensuse-tumbleweed
83 #, no-wrap
84 msgid ""
85 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
86 "B< const pthread_attr_t *_Nullable restrict >I<attr>B<,>\n"
87 "B< typeof(void *(void *_Nullable)) *>I<start_routine>B<,>\n"
88 "B< void *_Nullable restrict >I<arg>B<);>\n"
89 msgstr ""
90 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
91 "B< const pthread_attr_t *_Nullable restrict >I<attr>B<,>\n"
92 "B< typeof(void *(void *_Nullable)) *>I<start_routine>B<,>\n"
93 "B< void *_Nullable restrict >I<arg>B<);>\n"
94
95 #. type: SH
96 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
97 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
98 #, no-wrap
99 msgid "DESCRIPTION"
100 msgstr "الوصف"
101
102 #. type: Plain text
103 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
104 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
105 msgid ""
106 "The B<pthread_create>() function starts a new thread in the calling "
107 "process. The new thread starts execution by invoking I<start_routine>(); "
108 "I<arg> is passed as the sole argument of I<start_routine>()."
109 msgstr ""
110 "الدالة B<pthread_create>() تبدأ خيطًا جديدًا في العملية المستدعية. يبدأ الخيط "
111 "الجديد التنفيذ باستدعاء I<start_routine>()؛ يُمرر I<arg> كوسيط وحيد لـ "
112 "I<start_routine>()."
113
114 #. type: Plain text
115 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
116 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
117 msgid "The new thread terminates in one of the following ways:"
118 msgstr "ينتهي الخيط الجديد بإحدى الطرق التالية:"
119
120 #. type: IP
121 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
122 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
123 #, no-wrap
124 msgid "\\[bu]"
125 msgstr "\\[bu]"
126
127 #. type: Plain text
128 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
129 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
130 msgid ""
131 "It calls B<pthread_exit>(3), specifying an exit status value that is "
132 "available to another thread in the same process that calls "
133 "B<pthread_join>(3)."
134 msgstr ""
135 "يستدعي B<pthread_exit>(3)، محددًا قيمة حالة خروج متاحة لخيط آخر في نفس "
136 "العملية يستدعي B<pthread_join>(3)."
137
138 #. type: Plain text
139 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
140 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
141 msgid ""
142 "It returns from I<start_routine>(). This is equivalent to calling "
143 "B<pthread_exit>(3) with the value supplied in the I<return> statement."
144 msgstr ""
145 "يعود من I<start_routine>(). هذا يعادل استدعاء B<pthread_exit>(3) بالقيمة "
146 "المقدمة في عبارة I<return>."
147
148 #. type: Plain text
149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
151 msgid "It is canceled (see B<pthread_cancel>(3))."
152 msgstr "يُلغى (انظر B<pthread_cancel>(3))."
153
154 #. type: Plain text
155 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
156 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
157 msgid ""
158 "Any of the threads in the process calls B<exit>(3), or the main thread "
159 "performs a return from I<main>(). This causes the termination of all "
160 "threads in the process."
161 msgstr ""
162 "أي من الخيوط في العملية يستدعي B<exit>(3)، أو الخيط الرئيسي يعود من "
163 "I<main>(). هذا يسبب إنهاء جميع الخيوط في العملية."
164
165 #. type: Plain text
166 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
167 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
168 msgid ""
169 "The I<attr> argument points to a I<pthread_attr_t> structure whose contents "
170 "are used at thread creation time to determine attributes for the new thread; "
171 "this structure is initialized using B<pthread_attr_init>(3) and related "
172 "functions. If I<attr> is NULL, then the thread is created with default "
173 "attributes."
174 msgstr ""
175 "الوسيط I<attr> يشير إلى بنية I<pthread_attr_t> تُستخدم محتوياتها وقت إنشاء "
176 "الخيط لتحديد سمات الخيط الجديد؛ تُهيأ هذه البنية باستخدام "
177 "B<pthread_attr_init>(3) والدوال ذات الصلة. إذا كان I<attr> NULL، فسيُُنشأ "
178 "الخيط بسمات مبدئية."
179
180 #. type: Plain text
181 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
182 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
183 msgid ""
184 "Before returning, a successful call to B<pthread_create>() stores the ID of "
185 "the new thread in the buffer pointed to by I<thread>; this identifier is "
186 "used to refer to the thread in subsequent calls to other pthreads functions."
187 msgstr ""
188 "قبل العودة، يخزن استدعاء ناجح لـ B<pthread_create>() معرف الخيط الجديد في "
189 "المخزن المؤقت المشار إليه بـ I<thread>؛ يُستخدم هذا المعرف للإشارة إلى الخيط "
190 "في الاستدعاءات اللاحقة لدوال pthreads الأخرى."
191
192 #. type: Plain text
193 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
194 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
195 msgid ""
196 "The new thread inherits a copy of the creating thread's signal mask "
197 "(B<pthread_sigmask>(3)). The set of pending signals for the new thread is "
198 "empty (B<sigpending>(2)). The new thread does not inherit the creating "
199 "thread's alternate signal stack (B<sigaltstack>(2))."
200 msgstr ""
201 "يرث الخيط الجديد نسخة من قناع الإشارات للخيط المنشئ (B<pthread_sigmask>(3)). "
202 "مجموعة الإشارات المعلقة للخيط الجديد فارغة (B<sigpending>(2)). لا يرث الخيط "
203 "الجديد مكدس الإشارات البديل للخيط المنشئ (B<sigaltstack>(2))."
204
205 #. type: Plain text
206 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
207 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
208 msgid ""
209 "The new thread inherits the calling thread's floating-point environment "
210 "(B<fenv>(3))."
211 msgstr "يرث الخيط الجديد بيئة النقطة العائمة للخيط المستدعي (B<fenv>(3))."
212
213 #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
214 #. type: Plain text
215 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
216 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
217 msgid ""
218 "The initial value of the new thread's CPU-time clock is 0 (see "
219 "B<pthread_getcpuclockid>(3))."
220 msgstr ""
221 "القيمة المبدئية لساعة وقت وحدة المعالجة المركزية للخيط الجديد هي 0 (انظر "
222 "B<pthread_getcpuclockid>(3))."
223
224 #. type: SS
225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
227 #, no-wrap
228 msgid "Linux-specific details"
229 msgstr "تفاصيل خاصة بلينكس"
230
231 #. type: Plain text
232 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
233 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
234 msgid ""
235 "The new thread inherits copies of the calling thread's capability sets (see "
236 "B<capabilities>(7)) and CPU affinity mask (see B<sched_setaffinity>(2))."
237 msgstr ""
238 "يرث الخيط الجديد نسخًا من مجموعات القدرات للخيط المستدعي (انظر "
239 "B<capabilities>(7)) وقناع التقارب لوحدة المعالجة المركزية (انظر "
240 "B<sched_setaffinity>(2))."
241
242 #. type: SH
243 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
244 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
245 #, no-wrap
246 msgid "RETURN VALUE"
247 msgstr "قيمة الإرجاع"
248
249 #. type: Plain text
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 msgid ""
253 "On success, B<pthread_create>() returns 0; on error, it returns an error "
254 "number, and the contents of I<*thread> are undefined."
255 msgstr ""
256 "عند النجاح، تُرجع B<pthread_create>() 0؛ عند الخطأ، تُرجع رقم خطأ، ومحتويات "
257 "I<*thread> غير معرفة."
258
259 #. type: SH
260 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
261 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
262 #, no-wrap
263 msgid "ERRORS"
264 msgstr "الأخطاء"
265
266 #. type: TP
267 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
268 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
269 #, no-wrap
270 msgid "B<EAGAIN>"
271 msgstr "B<EAGAIN>"
272
273 #. type: Plain text
274 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
275 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
276 msgid "Insufficient resources to create another thread."
277 msgstr "موارد غير كافية لإنشاء خيط آخر."
278
279 #. NOTE! The following should match the description in fork(2)
280 #. type: Plain text
281 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
282 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
283 msgid ""
284 "A system-imposed limit on the number of threads was encountered. There are "
285 "a number of limits that may trigger this error: the B<RLIMIT_NPROC> soft "
286 "resource limit (set via B<setrlimit>(2)), which limits the number of "
287 "processes and threads for a real user ID, was reached; the kernel's system-"
288 "wide limit on the number of processes and threads, I</proc/sys/kernel/"
289 "threads-max>, was reached (see B<proc>(5)); or the maximum number of PIDs, "
290 "I</proc/sys/kernel/pid_max>, was reached (see B<proc>(5))."
291 msgstr ""
292 "وُجد حد يفرضه النظام على عدد الخيوط. هناك عدد من الحدود التي قد تسبب هذا "
293 "الخطأ: حد المورد الناعم B<RLIMIT_NPROC> (المُعيَّن عبر B<setrlimit>(2))، الذي "
294 "يحد عدد العمليات والخيوط لمعرف مستخدم حقيقي، وُصل إليه؛ حد النواة على مستوى "
295 "النظام لعدد العمليات والخيوط، I</proc/sys/kernel/threads-max>، وُصل إليه "
296 "(انظر B<proc>(5))؛ أو الحد الأقصى لعدد معرفات العمليات، I</proc/sys/kernel/"
297 "pid_max>، وُصل إليه (انظر B<proc>(5))."
298
299 #. type: TP
300 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
301 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
302 #, no-wrap
303 msgid "B<EINVAL>"
304 msgstr "B<EINVAL>"
305
306 #. type: Plain text
307 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
308 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
309 msgid "Invalid settings in I<attr>."
310 msgstr "إعدادات غير صالحة في I<attr>."
311
312 #. FIXME . Test the following
313 #. type: TP
314 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
315 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
316 #, no-wrap
317 msgid "B<EPERM>"
318 msgstr "B<EPERM>"
319
320 #. type: Plain text
321 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
322 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
323 msgid ""
324 "No permission to set the scheduling policy and parameters specified in "
325 "I<attr>."
326 msgstr "لا يوجد إذن لتعيين سياسة الجدولة والمعاملات المُحدَّدة في I<attr>."
327
328 #. type: SH
329 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
330 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
331 #, no-wrap
332 msgid "ATTRIBUTES"
333 msgstr "السمات"
334
335 #. type: Plain text
336 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
337 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
338 msgid ""
339 "For an explanation of the terms used in this section, see B<attributes>(7)."
340 msgstr ""
341 "للاطلاع على شرح للمصطلحات المستخدمة في هذا القسم، انظر B<attributes>(7)."
342
343 #. type: tbl table
344 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
345 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
346 #, no-wrap
347 msgid "Interface"
348 msgstr "الواجهة"
349
350 #. type: tbl table
351 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
352 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
353 #, no-wrap
354 msgid "Attribute"
355 msgstr "السمة"
356
357 #. type: tbl table
358 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
359 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
360 #, no-wrap
361 msgid "Value"
362 msgstr "القيمة"
363
364 #. type: tbl table
365 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
366 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
367 #, no-wrap
368 msgid ".na\n"
369 msgstr ".na\n"
370
371 #. type: tbl table
372 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
373 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
374 #, no-wrap
375 msgid ".nh\n"
376 msgstr ".nh\n"
377
378 #. type: tbl table
379 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
380 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
381 #, no-wrap
382 msgid "B<pthread_create>()"
383 msgstr "B<pthread_create>()"
384
385 #. type: tbl table
386 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
387 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
388 #, no-wrap
389 msgid "Thread safety"
390 msgstr "سلامة الخيوط"
391
392 #. type: tbl table
393 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
394 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
395 #, no-wrap
396 msgid "MT-Safe"
397 msgstr "MT-Safe"
398
399 #. type: SH
400 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
401 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
402 #, no-wrap
403 msgid "STANDARDS"
404 msgstr "المعايير"
405
406 #. type: Plain text
407 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
408 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
409 msgid "POSIX.1-2008."
410 msgstr "POSIX.1-2008."
411
412 #. type: SH
413 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
414 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
415 #, no-wrap
416 msgid "HISTORY"
417 msgstr "التاريخ"
418
419 #. type: Plain text
420 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
421 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
422 msgid "POSIX.1-2001."
423 msgstr "POSIX.1-2001."
424
425 #. type: SH
426 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
427 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
428 #, no-wrap
429 msgid "NOTES"
430 msgstr "ملاحظات"
431
432 #. type: Plain text
433 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
434 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
435 msgid ""
436 "See B<pthread_self>(3) for further information on the thread ID returned in "
437 "I<*thread> by B<pthread_create>(). Unless real-time scheduling policies are "
438 "being employed, after a call to B<pthread_create>(), it is indeterminate "
439 "which thread\\[em]the caller or the new thread\\[em]will next execute."
440 msgstr ""
441 "انظر B<pthread_self>(3) لمزيد من المعلومات حول معرف الخيط المُرجَع في "
442 "I<*thread> بواسطة B<pthread_create>(). ما لم تُستخدم سياسات جدولة زمن حقيقي، "
443 "بعد استدعاء B<pthread_create>()، يكون غير محدد أي خيط\\[em]المُستدعي أم الخيط "
444 "الجديد\\[em]سَيُنفَّذ بعد ذلك."
445
446 #. type: Plain text
447 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
448 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
449 msgid ""
450 "A thread may either be I<joinable> or I<detached>. If a thread is joinable, "
451 "then another thread can call B<pthread_join>(3) to wait for the thread to "
452 "terminate and fetch its exit status. Only when a terminated joinable thread "
453 "has been joined are the last of its resources released back to the system. "
454 "When a detached thread terminates, its resources are automatically released "
455 "back to the system: it is not possible to join with the thread in order to "
456 "obtain its exit status. Making a thread detached is useful for some types "
457 "of daemon threads whose exit status the application does not need to care "
458 "about. By default, a new thread is created in a joinable state, unless "
459 "I<attr> was set to create the thread in a detached state (using "
460 "B<pthread_attr_setdetachstate>(3))."
461 msgstr ""
462 "قد يكون الخيط إما I<قابلًا للانضمام> أو I<منفصلًا>. إذا كان الخيط قابلًا "
463 "للانضمام، فيمكن لخيط آخر استدعاء B<pthread_join>(3) لانتظار إنهاء الخيط وجلب "
464 "حالة خروجه. فقط عندما يُنضم إلى خيط قابل للانضمام مُنهى، تُحرَّر آخر موارده عائدةً "
465 "إلى النظام. عندما يُنهى خيط منفصل، تُحرَّر موارده آليًا عائدةً إلى النظام: لا يمكن "
466 "الانضمام إلى الخيط للحصول على حالة خروجه. جعل الخيط منفصلًا مفيد لبعض أنواع "
467 "خيوط البرامج الخفية التي لا يحتاج التطبيق للاهتمام بحالة خروجها. مبدئيًا، "
468 "يُنشأ خيط جديد في حالة قابلة للانضمام، ما لم يُضبط I<attr> لإنشاء الخيط في "
469 "حالة منفصلة (باستخدام B<pthread_attr_setdetachstate>(3))."
470
471 #. type: Plain text
472 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
473 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
474 msgid ""
475 "Under the NPTL threading implementation, if the B<RLIMIT_STACK> soft "
476 "resource limit I<at the time the program started> has any value other than "
477 "\"unlimited\", then it determines the default stack size of new threads. "
478 "Using B<pthread_attr_setstacksize>(3), the stack size attribute can be "
479 "explicitly set in the I<attr> argument used to create a thread, in order to "
480 "obtain a stack size other than the default. If the B<RLIMIT_STACK> resource "
481 "limit is set to \"unlimited\", a per-architecture value is used for the "
482 "stack size: 2 MB on most architectures; 4 MB on POWER and Sparc-64."
483 msgstr ""
484 "تحت تنفيذ الخيوط NPTL، إذا كان حد المورد اللين B<RLIMIT_STACK> I<عند وقت بدء "
485 "البرنامج> له أي قيمة غير \"غير محدود\"، فإنه يُحدد الحجم المبدئي لمكدس الخيوط "
486 "الجديدة. باستخدام B<pthread_attr_setstacksize>(3)، يمكن ضبط سمة حجم المكدس "
487 "صراحةً في وسيط I<attr> المُستخدم لإنشاء خيط، للحصول على حجم مكدس غير المبدئي. "
488 "إذا ضُبط حد المورد B<RLIMIT_STACK> على \"غير محدود\"، تُستخدم قيمة حسب "
489 "المعمارية لحجم المكدس: 2 ميغابايت على معظم المعماريات؛ 4 ميغابايت على POWER "
490 "وSparc-64."
491
492 #. type: SH
493 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
494 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
495 #, no-wrap
496 msgid "BUGS"
497 msgstr "العلل"
498
499 #. type: Plain text
500 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
501 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
502 msgid ""
503 "In the obsolete LinuxThreads implementation, each of the threads in a "
504 "process has a different process ID. This is in violation of the POSIX "
505 "threads specification, and is the source of many other nonconformances to "
506 "the standard; see B<pthreads>(7)."
507 msgstr ""
508 "في تنفيذ LinuxThreads المُتقادم، لكل خيط من خيوط العملية معرف عملية مختلف. "
509 "هذا انتهاك لمواصفات خيوط POSIX، وهو مصدر العديد من حالات عدم المطابقة الأخرى "
510 "للمعيار؛ انظر B<pthreads>(7)."
511
512 #. type: SH
513 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
514 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
515 #, no-wrap
516 msgid "EXAMPLES"
517 msgstr "أمثلة"
518
519 #. type: Plain text
520 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
521 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
522 msgid ""
523 "The program below demonstrates the use of B<pthread_create>(), as well as a "
524 "number of other functions in the pthreads API."
525 msgstr ""
526 "البرنامج أدناه يُوضح استخدام B<pthread_create>()، بالإضافة إلى عدد من الدوال "
527 "الأخرى في واجهة برمجة تطبيقات pthreads."
528
529 #. type: Plain text
530 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
531 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
532 msgid ""
533 "In the following run, on a system providing the NPTL threading "
534 "implementation, the stack size defaults to the value given by the \"stack "
535 "size\" resource limit:"
536 msgstr ""
537 "في التشغيل التالي، على نظام يُوفر تنفيذ الخيوط NPTL، الحجم المبدئي للمكدس هو "
538 "القيمة المُعطاة بواسطة حد المورد \"حجم المكدس\":"
539
540 #. type: Plain text
541 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
542 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
543 #, no-wrap
544 msgid ""
545 "$B< ulimit -s>\n"
546 "8192 # The stack size limit is 8 MB (0x800000 bytes)\n"
547 "$B< ./a.out hola salut servus>\n"
548 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
549 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
550 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
551 "Joined with thread 1; returned value was HOLA\n"
552 "Joined with thread 2; returned value was SALUT\n"
553 "Joined with thread 3; returned value was SERVUS\n"
554 msgstr ""
555 "$B< ulimit -s>\n"
556 "8192 # The stack size limit is 8 MB (0x800000 bytes)\n"
557 "$B< ./a.out hola salut servus>\n"
558 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
559 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
560 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
561 "Joined with thread 1; returned value was HOLA\n"
562 "Joined with thread 2; returned value was SALUT\n"
563 "Joined with thread 3; returned value was SERVUS\n"
564
565 #. type: Plain text
566 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
567 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
568 msgid ""
569 "In the next run, the program explicitly sets a stack size of 1\\ MB (using "
570 "B<pthread_attr_setstacksize>(3)) for the created threads:"
571 msgstr ""
572 "في التشغيل التالي، البرنامج يضبط صراحةً حجم مكدس قدره 1\\ ميغابايت (باستخدام "
573 "B<pthread_attr_setstacksize>(3)) للخيوط المُنشأة:"
574
575 #. type: Plain text
576 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
577 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
578 #, no-wrap
579 msgid ""
580 "$B< ./a.out -s 0x100000 hola salut servus>\n"
581 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
582 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
583 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
584 "Joined with thread 1; returned value was HOLA\n"
585 "Joined with thread 2; returned value was SALUT\n"
586 "Joined with thread 3; returned value was SERVUS\n"
587 msgstr ""
588 "$B< ./a.out -s 0x100000 hola salut servus>\n"
589 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
590 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
591 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
592 "Joined with thread 1; returned value was HOLA\n"
593 "Joined with thread 2; returned value was SALUT\n"
594 "Joined with thread 3; returned value was SERVUS\n"
595
596 #. type: SS
597 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
598 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
599 #, no-wrap
600 msgid "Program source"
601 msgstr "مصدر البرنامج"
602
603 #. type: Plain text
604 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
605 #: opensuse-tumbleweed
606 #, no-wrap
607 msgid ""
608 "#include E<lt>ctype.hE<gt>\n"
609 "#include E<lt>err.hE<gt>\n"
610 "#include E<lt>pthread.hE<gt>\n"
611 "#include E<lt>stdio.hE<gt>\n"
612 "#include E<lt>stdlib.hE<gt>\n"
613 "#include E<lt>string.hE<gt>\n"
614 "#include E<lt>sys/types.hE<gt>\n"
615 "#include E<lt>unistd.hE<gt>\n"
616 "\\&\n"
617 "struct thread_info { /* Used as argument to thread_start() */\n"
618 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
619 " int thread_num; /* Application-defined thread # */\n"
620 " char *argv_string; /* From command-line argument */\n"
621 "};\n"
622 "\\&\n"
623 "/* Thread start function: display address near top of our stack,\n"
624 " and return upper-cased copy of argv_string. */\n"
625 "\\&\n"
626 "static void *\n"
627 "thread_start(void *arg)\n"
628 "{\n"
629 " struct thread_info *tinfo = arg;\n"
630 " char *uargv;\n"
631 "\\&\n"
632 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
633 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
634 "\\&\n"
635 " uargv = strdup(tinfo-E<gt>argv_string);\n"
636 " if (uargv == NULL)\n"
637 " err(EXIT_FAILURE, \"strdup\");\n"
638 "\\&\n"
639 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
640 " *p = toupper(*p);\n"
641 "\\&\n"
642 " return uargv;\n"
643 "}\n"
644 "\\&\n"
645 "int\n"
646 "main(int argc, char *argv[])\n"
647 "{\n"
648 " int s, opt;\n"
649 " void *res;\n"
650 " size_t num_threads;\n"
651 " ssize_t stack_size;\n"
652 " pthread_attr_t attr;\n"
653 " struct thread_info *tinfo;\n"
654 "\\&\n"
655 " /* The \"-s\" option specifies a stack size for our threads. */\n"
656 "\\&\n"
657 " stack_size = -1;\n"
658 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
659 " switch (opt) {\n"
660 " case \\[aq]s\\[aq]:\n"
661 " stack_size = strtoul(optarg, NULL, 0);\n"
662 " break;\n"
663 "\\&\n"
664 " default:\n"
665 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
666 " argv[0]);\n"
667 " exit(EXIT_FAILURE);\n"
668 " }\n"
669 " }\n"
670 "\\&\n"
671 " num_threads = argc - optind;\n"
672 "\\&\n"
673 " /* Initialize thread creation attributes. */\n"
674 "\\&\n"
675 " s = pthread_attr_init(&attr);\n"
676 " if (s != 0)\n"
677 " errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n"
678 "\\&\n"
679 " if (stack_size E<gt> 0) {\n"
680 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
681 " if (s != 0)\n"
682 " errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n"
683 " }\n"
684 "\\&\n"
685 " /* Allocate memory for pthread_create() arguments. */\n"
686 "\\&\n"
687 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
688 " if (tinfo == NULL)\n"
689 " err(EXIT_FAILURE, \"calloc\");\n"
690 "\\&\n"
691 " /* Create one thread for each command-line argument. */\n"
692 "\\&\n"
693 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
694 " tinfo[tnum].thread_num = tnum + 1;\n"
695 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
696 "\\&\n"
697 " /* The pthread_create() call stores the thread ID into\n"
698 " corresponding element of tinfo[]. */\n"
699 "\\&\n"
700 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
701 " &thread_start, &tinfo[tnum]);\n"
702 " if (s != 0)\n"
703 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
704 " }\n"
705 "\\&\n"
706 " /* Destroy the thread attributes object, since it is no\n"
707 " longer needed. */\n"
708 "\\&\n"
709 " s = pthread_attr_destroy(&attr);\n"
710 " if (s != 0)\n"
711 " errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n"
712 "\\&\n"
713 " /* Now join with each thread, and display its returned value. */\n"
714 "\\&\n"
715 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
716 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
717 " if (s != 0)\n"
718 " errc(EXIT_FAILURE, s, \"pthread_join\");\n"
719 "\\&\n"
720 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
721 " tinfo[tnum].thread_num, (char *) res);\n"
722 " free(res); /* Free memory allocated by thread */\n"
723 " }\n"
724 "\\&\n"
725 " free(tinfo);\n"
726 " exit(EXIT_SUCCESS);\n"
727 "}\n"
728 msgstr ""
729 "#include E<lt>ctype.hE<gt>\n"
730 "#include E<lt>err.hE<gt>\n"
731 "#include E<lt>pthread.hE<gt>\n"
732 "#include E<lt>stdio.hE<gt>\n"
733 "#include E<lt>stdlib.hE<gt>\n"
734 "#include E<lt>string.hE<gt>\n"
735 "#include E<lt>sys/types.hE<gt>\n"
736 "#include E<lt>unistd.hE<gt>\n"
737 "\\&\n"
738 "struct thread_info { /* Used as argument to thread_start() */\n"
739 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
740 " int thread_num; /* Application-defined thread # */\n"
741 " char *argv_string; /* From command-line argument */\n"
742 "};\n"
743 "\\&\n"
744 "/* Thread start function: display address near top of our stack,\n"
745 " and return upper-cased copy of argv_string. */\n"
746 "\\&\n"
747 "static void *\n"
748 "thread_start(void *arg)\n"
749 "{\n"
750 " struct thread_info *tinfo = arg;\n"
751 " char *uargv;\n"
752 "\\&\n"
753 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
754 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
755 "\\&\n"
756 " uargv = strdup(tinfo-E<gt>argv_string);\n"
757 " if (uargv == NULL)\n"
758 " err(EXIT_FAILURE, \"strdup\");\n"
759 "\\&\n"
760 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
761 " *p = toupper(*p);\n"
762 "\\&\n"
763 " return uargv;\n"
764 "}\n"
765 "\\&\n"
766 "int\n"
767 "main(int argc, char *argv[])\n"
768 "{\n"
769 " int s, opt;\n"
770 " void *res;\n"
771 " size_t num_threads;\n"
772 " ssize_t stack_size;\n"
773 " pthread_attr_t attr;\n"
774 " struct thread_info *tinfo;\n"
775 "\\&\n"
776 " /* The \"-s\" option specifies a stack size for our threads. */\n"
777 "\\&\n"
778 " stack_size = -1;\n"
779 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
780 " switch (opt) {\n"
781 " case \\[aq]s\\[aq]:\n"
782 " stack_size = strtoul(optarg, NULL, 0);\n"
783 " break;\n"
784 "\\&\n"
785 " default:\n"
786 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
787 " argv[0]);\n"
788 " exit(EXIT_FAILURE);\n"
789 " }\n"
790 " }\n"
791 "\\&\n"
792 " num_threads = argc - optind;\n"
793 "\\&\n"
794 " /* Initialize thread creation attributes. */\n"
795 "\\&\n"
796 " s = pthread_attr_init(&attr);\n"
797 " if (s != 0)\n"
798 " errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n"
799 "\\&\n"
800 " if (stack_size E<gt> 0) {\n"
801 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
802 " if (s != 0)\n"
803 " errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n"
804 " }\n"
805 "\\&\n"
806 " /* Allocate memory for pthread_create() arguments. */\n"
807 "\\&\n"
808 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
809 " if (tinfo == NULL)\n"
810 " err(EXIT_FAILURE, \"calloc\");\n"
811 "\\&\n"
812 " /* Create one thread for each command-line argument. */\n"
813 "\\&\n"
814 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
815 " tinfo[tnum].thread_num = tnum + 1;\n"
816 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
817 "\\&\n"
818 " /* The pthread_create() call stores the thread ID into\n"
819 " corresponding element of tinfo[]. */\n"
820 "\\&\n"
821 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
822 " &thread_start, &tinfo[tnum]);\n"
823 " if (s != 0)\n"
824 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
825 " }\n"
826 "\\&\n"
827 " /* Destroy the thread attributes object, since it is no\n"
828 " longer needed. */\n"
829 "\\&\n"
830 " s = pthread_attr_destroy(&attr);\n"
831 " if (s != 0)\n"
832 " errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n"
833 "\\&\n"
834 " /* Now join with each thread, and display its returned value. */\n"
835 "\\&\n"
836 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
837 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
838 " if (s != 0)\n"
839 " errc(EXIT_FAILURE, s, \"pthread_join\");\n"
840 "\\&\n"
841 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
842 " tinfo[tnum].thread_num, (char *) res);\n"
843 " free(res); /* Free memory allocated by thread */\n"
844 " }\n"
845 "\\&\n"
846 " free(tinfo);\n"
847 " exit(EXIT_SUCCESS);\n"
848 "}\n"
849
850 #. SRC END
851 #. type: SH
852 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
853 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
854 #, no-wrap
855 msgid "SEE ALSO"
856 msgstr "انظر أيضًا"
857
858 #. type: Plain text
859 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
860 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
861 msgid ""
862 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
863 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
864 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), "
865 "B<pthread_setattr_default_np>(3), B<pthreads>(7)"
866 msgstr ""
867 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
868 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
869 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), "
870 "B<pthread_setattr_default_np>(3), B<pthreads>(7)"
871
872 #. type: TH
873 #: debian-trixie
874 #, no-wrap
875 msgid "2024-06-15"
876 msgstr "15 يونيو 2024"
877
878 #. type: TH
879 #: debian-trixie
880 #, no-wrap
881 msgid "Linux man-pages 6.9.1"
882 msgstr "صفحات دليل لينكس 6.9.1"
883
884 #. type: Plain text
885 #: debian-trixie
886 msgid "POSIX threads library (I<libpthread>, I<-lpthread>)"
887 msgstr "مكتبة مسالك POSIX (I<libpthread>، I<-lpthread>)"
888
889 #. type: Plain text
890 #: debian-trixie
891 #, no-wrap
892 msgid ""
893 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
894 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
895 "B< void *(*>I<start_routine>B<)(void *),>\n"
896 "B< void *restrict >I<arg>B<);>\n"
897 msgstr ""
898 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
899 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
900 "B< void *(*>I<start_routine>B<)(void *),>\n"
901 "B< void *restrict >I<arg>B<);>\n"
902
903 #. type: Plain text
904 #: debian-trixie fedora-44 fedora-rawhide
905 #, no-wrap
906 msgid ""
907 "#include E<lt>ctype.hE<gt>\n"
908 "#include E<lt>errno.hE<gt>\n"
909 "#include E<lt>pthread.hE<gt>\n"
910 "#include E<lt>stdio.hE<gt>\n"
911 "#include E<lt>stdlib.hE<gt>\n"
912 "#include E<lt>string.hE<gt>\n"
913 "#include E<lt>sys/types.hE<gt>\n"
914 "#include E<lt>unistd.hE<gt>\n"
915 "\\&\n"
916 "#define handle_error_en(en, msg) \\[rs]\n"
917 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
918 "\\&\n"
919 "#define handle_error(msg) \\[rs]\n"
920 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
921 "\\&\n"
922 "struct thread_info { /* Used as argument to thread_start() */\n"
923 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
924 " int thread_num; /* Application-defined thread # */\n"
925 " char *argv_string; /* From command-line argument */\n"
926 "};\n"
927 "\\&\n"
928 "/* Thread start function: display address near top of our stack,\n"
929 " and return upper-cased copy of argv_string. */\n"
930 "\\&\n"
931 "static void *\n"
932 "thread_start(void *arg)\n"
933 "{\n"
934 " struct thread_info *tinfo = arg;\n"
935 " char *uargv;\n"
936 "\\&\n"
937 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
938 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
939 "\\&\n"
940 " uargv = strdup(tinfo-E<gt>argv_string);\n"
941 " if (uargv == NULL)\n"
942 " handle_error(\"strdup\");\n"
943 "\\&\n"
944 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
945 " *p = toupper(*p);\n"
946 "\\&\n"
947 " return uargv;\n"
948 "}\n"
949 "\\&\n"
950 "int\n"
951 "main(int argc, char *argv[])\n"
952 "{\n"
953 " int s, opt;\n"
954 " void *res;\n"
955 " size_t num_threads;\n"
956 " ssize_t stack_size;\n"
957 " pthread_attr_t attr;\n"
958 " struct thread_info *tinfo;\n"
959 "\\&\n"
960 " /* The \"-s\" option specifies a stack size for our threads. */\n"
961 "\\&\n"
962 " stack_size = -1;\n"
963 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
964 " switch (opt) {\n"
965 " case \\[aq]s\\[aq]:\n"
966 " stack_size = strtoul(optarg, NULL, 0);\n"
967 " break;\n"
968 "\\&\n"
969 " default:\n"
970 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
971 " argv[0]);\n"
972 " exit(EXIT_FAILURE);\n"
973 " }\n"
974 " }\n"
975 "\\&\n"
976 " num_threads = argc - optind;\n"
977 "\\&\n"
978 " /* Initialize thread creation attributes. */\n"
979 "\\&\n"
980 " s = pthread_attr_init(&attr);\n"
981 " if (s != 0)\n"
982 " handle_error_en(s, \"pthread_attr_init\");\n"
983 "\\&\n"
984 " if (stack_size E<gt> 0) {\n"
985 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
986 " if (s != 0)\n"
987 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
988 " }\n"
989 "\\&\n"
990 " /* Allocate memory for pthread_create() arguments. */\n"
991 "\\&\n"
992 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
993 " if (tinfo == NULL)\n"
994 " handle_error(\"calloc\");\n"
995 "\\&\n"
996 " /* Create one thread for each command-line argument. */\n"
997 "\\&\n"
998 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
999 " tinfo[tnum].thread_num = tnum + 1;\n"
1000 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
1001 "\\&\n"
1002 " /* The pthread_create() call stores the thread ID into\n"
1003 " corresponding element of tinfo[]. */\n"
1004 "\\&\n"
1005 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
1006 " &thread_start, &tinfo[tnum]);\n"
1007 " if (s != 0)\n"
1008 " handle_error_en(s, \"pthread_create\");\n"
1009 " }\n"
1010 "\\&\n"
1011 " /* Destroy the thread attributes object, since it is no\n"
1012 " longer needed. */\n"
1013 "\\&\n"
1014 " s = pthread_attr_destroy(&attr);\n"
1015 " if (s != 0)\n"
1016 " handle_error_en(s, \"pthread_attr_destroy\");\n"
1017 "\\&\n"
1018 " /* Now join with each thread, and display its returned value. */\n"
1019 "\\&\n"
1020 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
1021 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
1022 " if (s != 0)\n"
1023 " handle_error_en(s, \"pthread_join\");\n"
1024 "\\&\n"
1025 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
1026 " tinfo[tnum].thread_num, (char *) res);\n"
1027 " free(res); /* Free memory allocated by thread */\n"
1028 " }\n"
1029 "\\&\n"
1030 " free(tinfo);\n"
1031 " exit(EXIT_SUCCESS);\n"
1032 "}\n"
1033 msgstr ""
1034 "#include E<lt>ctype.hE<gt>\n"
1035 "#include E<lt>errno.hE<gt>\n"
1036 "#include E<lt>pthread.hE<gt>\n"
1037 "#include E<lt>stdio.hE<gt>\n"
1038 "#include E<lt>stdlib.hE<gt>\n"
1039 "#include E<lt>string.hE<gt>\n"
1040 "#include E<lt>sys/types.hE<gt>\n"
1041 "#include E<lt>unistd.hE<gt>\n"
1042 "\\&\n"
1043 "#define handle_error_en(en, msg) \\[rs]\n"
1044 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
1045 "\\&\n"
1046 "#define handle_error(msg) \\[rs]\n"
1047 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
1048 "\\&\n"
1049 "struct thread_info { /* Used as argument to thread_start() */\n"
1050 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
1051 " int thread_num; /* Application-defined thread # */\n"
1052 " char *argv_string; /* From command-line argument */\n"
1053 "};\n"
1054 "\\&\n"
1055 "/* Thread start function: display address near top of our stack,\n"
1056 " and return upper-cased copy of argv_string. */\n"
1057 "\\&\n"
1058 "static void *\n"
1059 "thread_start(void *arg)\n"
1060 "{\n"
1061 " struct thread_info *tinfo = arg;\n"
1062 " char *uargv;\n"
1063 "\\&\n"
1064 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
1065 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
1066 "\\&\n"
1067 " uargv = strdup(tinfo-E<gt>argv_string);\n"
1068 " if (uargv == NULL)\n"
1069 " handle_error(\"strdup\");\n"
1070 "\\&\n"
1071 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
1072 " *p = toupper(*p);\n"
1073 "\\&\n"
1074 " return uargv;\n"
1075 "}\n"
1076 "\\&\n"
1077 "int\n"
1078 "main(int argc, char *argv[])\n"
1079 "{\n"
1080 " int s, opt;\n"
1081 " void *res;\n"
1082 " size_t num_threads;\n"
1083 " ssize_t stack_size;\n"
1084 " pthread_attr_t attr;\n"
1085 " struct thread_info *tinfo;\n"
1086 "\\&\n"
1087 " /* The \"-s\" option specifies a stack size for our threads. */\n"
1088 "\\&\n"
1089 " stack_size = -1;\n"
1090 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
1091 " switch (opt) {\n"
1092 " case \\[aq]s\\[aq]:\n"
1093 " stack_size = strtoul(optarg, NULL, 0);\n"
1094 " break;\n"
1095 "\\&\n"
1096 " default:\n"
1097 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
1098 " argv[0]);\n"
1099 " exit(EXIT_FAILURE);\n"
1100 " }\n"
1101 " }\n"
1102 "\\&\n"
1103 " num_threads = argc - optind;\n"
1104 "\\&\n"
1105 " /* Initialize thread creation attributes. */\n"
1106 "\\&\n"
1107 " s = pthread_attr_init(&attr);\n"
1108 " if (s != 0)\n"
1109 " handle_error_en(s, \"pthread_attr_init\");\n"
1110 "\\&\n"
1111 " if (stack_size E<gt> 0) {\n"
1112 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
1113 " if (s != 0)\n"
1114 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
1115 " }\n"
1116 "\\&\n"
1117 " /* Allocate memory for pthread_create() arguments. */\n"
1118 "\\&\n"
1119 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
1120 " if (tinfo == NULL)\n"
1121 " handle_error(\"calloc\");\n"
1122 "\\&\n"
1123 " /* Create one thread for each command-line argument. */\n"
1124 "\\&\n"
1125 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
1126 " tinfo[tnum].thread_num = tnum + 1;\n"
1127 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
1128 "\\&\n"
1129 " /* The pthread_create() call stores the thread ID into\n"
1130 " corresponding element of tinfo[]. */\n"
1131 "\\&\n"
1132 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
1133 " &thread_start, &tinfo[tnum]);\n"
1134 " if (s != 0)\n"
1135 " handle_error_en(s, \"pthread_create\");\n"
1136 " }\n"
1137 "\\&\n"
1138 " /* Destroy the thread attributes object, since it is no\n"
1139 " longer needed. */\n"
1140 "\\&\n"
1141 " s = pthread_attr_destroy(&attr);\n"
1142 " if (s != 0)\n"
1143 " handle_error_en(s, \"pthread_attr_destroy\");\n"
1144 "\\&\n"
1145 " /* Now join with each thread, and display its returned value. */\n"
1146 "\\&\n"
1147 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
1148 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
1149 " if (s != 0)\n"
1150 " handle_error_en(s, \"pthread_join\");\n"
1151 "\\&\n"
1152 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
1153 " tinfo[tnum].thread_num, (char *) res);\n"
1154 " free(res); /* Free memory allocated by thread */\n"
1155 " }\n"
1156 "\\&\n"
1157 " free(tinfo);\n"
1158 " exit(EXIT_SUCCESS);\n"
1159 "}\n"
1160
1161 #. type: TH
1162 #: fedora-44 fedora-rawhide
1163 #, no-wrap
1164 msgid "2024-12-13"
1165 msgstr "13 ديسمبر 2024"
1166
1167 #. type: TH
1168 #: fedora-44 fedora-rawhide
1169 #, no-wrap
1170 msgid "Linux man-pages 6.13"
1171 msgstr "صفحات دليل لينكس 6.13"
1172
1173 #. type: Plain text
1174 #: fedora-44 fedora-rawhide
1175 #, no-wrap
1176 msgid ""
1177 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
1178 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
1179 "B< typeof(void *(void *)) *>I<start_routine>B<,>\n"
1180 "B< void *restrict >I<arg>B<);>\n"
1181 msgstr ""
1182 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
1183 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
1184 "B< typeof(void *(void *)) *>I<start_routine>B<,>\n"
1185 "B< void *restrict >I<arg>B<);>\n"
1186
1187 #. type: TH
1188 #: mageia-cauldron
1189 #, no-wrap
1190 msgid "Linux man-pages 6.17"
1191 msgstr "صفحات دليل لينكس 6.17"
1192
1193 #. type: TH
1194 #: opensuse-leap-16-1 opensuse-tumbleweed
1195 #, no-wrap
1196 msgid "Linux man-pages (unreleased)"
1197 msgstr "صفحات دليل لينكس (لم تصدر بعد)"