.\" -*- coding: UTF-8 -*- '\" t .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH pthread_setschedparam 3 "21 سبتمبر 2025" "صفحات دليل لينكس 6.18" .SH الاسم pthread_setschedparam, pthread_getschedparam \- ضبط/الحصول على سياسة الجدولة ومعاملات خيط .SH المكتبة مكتبة مسالك POSIX (\fIlibpthread\fP،\ \fI\-lpthread\fP) .SH موجز .nf \fB#include \fP .P \fBint pthread_setschedparam(pthread_t \fP\fIthread\fP\fB, int \fP\fIpolicy\fP\fB,\fP \fB const struct sched_param *\fP\fIparam\fP\fB);\fP \fBint pthread_getschedparam(pthread_t \fP\fIthread\fP\fB, int *restrict \fP\fIpolicy\fP\fB,\fP \fB struct sched_param *restrict \fP\fIparam\fP\fB);\fP .fi .SH الوصف تضبط الدالة \fBpthread_setschedparam\fP() سياسة الجدولة ومعاملات الخيط \fIthread\fP. .P .\" FIXME . pthread_setschedparam() places no restriction on the policy, .\" but pthread_attr_setschedpolicy() restricts policy to RR/FIFO/OTHER .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7013 يحدد \fIpolicy\fP سياسة الجدولة الجديدة لـ \fIthread\fP. القيم المدعومة لـ \fIpolicy\fP ودلالاتها موصوفة في \fBsched\fP(7). .P تحدد البنية المشار إليها بـ \fIparam\fP معاملات الجدولة الجديدة لـ \fIthread\fP. تُحتفظ معاملات الجدولة في البنية التالية: .P .in +4n .EX struct sched_param { int sched_priority; /* أولوية الجدولة */ }; .EE .in .P كما هو موضح، يُدعم معامل جدولة واحد فقط. لتفاصيل النطاقات المسموح بها لأولويات الجدولة في كل سياسة جدولة، انظر \fBsched\fP(7). .P .\" FIXME . nptl/pthread_setschedparam.c has the following .\" /* If the thread should have higher priority because of some .\" PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */ .\" Eventually (perhaps after writing the mutexattr pages), we .\" may want to add something on the topic to this page. تُرجع الدالة \fBpthread_getschedparam\fP() سياسة الجدولة ومعاملات الخيط \fIthread\fP، في المخازن المؤقتة المشار إليها بـ \fIpolicy\fP و \fIparam\fP، على التوالي. قيمة الأولوية المُرجعة هي تلك التي ضُبطت بواسطة أحدث استدعاء لـ \fBpthread_setschedparam\fP() أو \fBpthread_setschedprio\fP(3) أو \fBpthread_create\fP(3) الذي أثر على \fIthread\fP. لا تعكس الأولوية المُرجعة أي تعديلات مؤقتة في الأولوية نتيجة استدعاءات لدوال وراثة الأولوية أو سقف الأولوية (انظر، على سبيل المثال، \fBpthread_mutexattr_setprioceiling\fP(3) و \fBpthread_mutexattr_setprotocol\fP(3)). .SH "قيمة الإرجاع" عند النجاح، تُرجع هاتان الدالتان 0؛ عند الخطأ، تُرجعان رقم خطأ غير صفري. إذا فشلت \fBpthread_setschedparam\fP()، لا تُغير سياسة الجدولة ومعاملات \fIthread\fP. .SH الأخطاء يمكن أن تفشل كلتا الدالتين مع الخطأ التالي: .TP \fBESRCH\fP تعذر العثور على أي خيط بالمعرف \fIthread\fP. .P قد تفشل \fBpthread_setschedparam\fP() بالإضافة إلى ذلك مع الأخطاء التالية: .TP \fBEINVAL\fP \fIpolicy\fP ليست سياسة معروفة، أو \fIparam\fP غير منطقي بالنسبة لـ \fIpolicy\fP. .TP \fBEPERM\fP لا يمتلك المستدعي الصلاحيات المناسبة لضبط سياسة الجدولة والمعاملات المحددة. .P يُوثق POSIX.1 أيضًا خطأ \fBENOTSUP\fP ("جرت محاولة لضبط السياسة أو معاملات الجدولة إلى قيمة غير مدعومة") لـ \fBpthread_setschedparam\fP(). .SH السمات للاطلاع على شرح للمصطلحات المستخدمة في هذا القسم، انظر \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. الواجهة السمة القيمة T{ .na .nh \fBpthread_setschedparam\fP(), \fBpthread_getschedparam\fP() T} سلامة الخيوط MT\-Safe .TE .SH المعايير POSIX.1\-2008. .SH التاريخ glibc 2.0 POSIX.1\-2001. .SH ملاحظات للحصول على وصف للصلاحيات المطلوبة لتغيير سياسة جدولة خيط وأولويته، وتأثير ذلك، وتفاصيل النطاقات المسموح بها للأولويات في كل سياسة جدولة، انظر \fBsched\fP(7). .SH أمثلة يوضح البرنامج أدناه استخدام \fBpthread_setschedparam\fP() و \fBpthread_getschedparam\fP()، بالإضافة إلى استخدام عدد من دوال pthreads الأخرى المتعلقة بالجدولة. .P في التشغيل التالي، يضبط الخيط الرئيسي سياسة الجدولة الخاصة به إلى \fBSCHED_FIFO\fP بأولوية 10، ويُهيئ كائن سمات خيط بسمة سياسة جدولة \fBSCHED_RR\fP وسمة أولوية جدولة 20. ثم يضبط البرنامج (باستخدام \fBpthread_attr_setinheritsched\fP(3)) سمة وراثة الجدولة لكائن سمات الخيط إلى \fBPTHREAD_EXPLICIT_SCHED\fP، مما يعني أن الخيوط المُنشأة باستخدام كائن السمات هذا يجب أن تأخذ سمات الجدولة الخاصة بها من كائن سمات الخيط. ثم ينشئ البرنامج خيطًا باستخدام كائن سمات الخيط، ويعرض ذلك الخيط سياسة الجدولة والأولوية الخاصة به. .P .in +4n .EX $\fB su\fP; # Need privilege to set real\-time scheduling policies Password: #\fB ./a.out \-mf10 \-ar20 \-i e\fP; Scheduler settings of main thread policy=SCHED_FIFO, priority=10 \& Scheduler settings in \[aq]attr\[aq] policy=SCHED_RR, priority=20 inheritsched is EXPLICIT \& Scheduler attributes of new thread policy=SCHED_RR, priority=20 .EE .in .P في المخرجات أعلاه، يمكن رؤية أن سياسة الجدولة والأولوية أُخذت من القيم المحددة في كائن سمات الخيط. .P التشغيل التالي هو نفسه السابق، باستثناء أن سمة وراثة الجدولة ضُبطت إلى \fBPTHREAD_INHERIT_SCHED\fP، مما يعني أن الخيوط المُنشأة باستخدام كائن سمات الخيط يجب أن تتجاهل سمات الجدولة المحددة في كائن السمات وتأخذ بدلاً من ذلك سمات الجدولة الخاصة بها من الخيط المُنشئ. .P .in +4n .EX #\fB ./a.out \-mf10 \-ar20 \-i i\fP; Scheduler settings of main thread policy=SCHED_FIFO, priority=10 \& Scheduler settings in \[aq]attr\[aq] policy=SCHED_RR, priority=20 inheritsched is INHERIT \& Scheduler attributes of new thread policy=SCHED_FIFO, priority=10 .EE .in .P في المخرجات أعلاه، يمكن رؤية أن سياسة الجدولة والأولوية أُخذت من الخيط المنشئ، وليس من كائن سمات الخيط. .P لاحظ أنه لو حذفنا الخيار \fI\-i\ i\fP، لكان المخرج نفسه، لأن \fBPTHREAD_INHERIT_SCHED\fP هو المبدئي لسمة الجدولة الموروثة. .SS "مصدر البرنامج" .\" SRC BEGIN (pthreads_sched_test.c) \& .EX /* pthreads_sched_test.c */ \& #include #include #include #include #include #include \& [[noreturn]] static void usage(char *prog_name, char *msg) { if (msg != NULL) fputs(msg, stderr); \& fprintf(stderr, "Usage: %s [options]\[rs]n", prog_name); fprintf(stderr, "Options are:\[rs]n"); #define fpe(msg) fprintf(stderr, "\[rs]t%s", msg) /* Shorter */ fpe("\-a Set scheduling policy and priority in\[rs]n"); fpe(" thread attributes object\[rs]n"); fpe(" can be\[rs]n"); fpe(" f SCHED_FIFO\[rs]n"); fpe(" r SCHED_RR\[rs]n"); fpe(" o SCHED_OTHER\[rs]n"); fpe("\-A Use default thread attributes object\[rs]n"); fpe("\-i {e|i} Set inherit scheduler attribute to\[rs]n"); fpe(" \[aq]explicit\[aq] or \[aq]inherit\[aq]\[rs]n"); fpe("\-m Set scheduling policy and priority on\[rs]n"); fpe(" main thread before pthread_create() call\[rs]n"); exit(EXIT_FAILURE); } \& static int get_policy(char p, int *policy) { switch (p) { case \[aq]f\[aq]: *policy = SCHED_FIFO; return 1; case \[aq]r\[aq]: *policy = SCHED_RR; return 1; case \[aq]o\[aq]: *policy = SCHED_OTHER; return 1; default: return 0; } } \& static void display_sched_attr(int policy, const struct sched_param *param) { printf(" policy=%s, priority=%d\[rs]n", (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : "???", param\->sched_priority); } \& static void display_thread_sched_attr(char *msg) { int policy, s; struct sched_param param; \& s = pthread_getschedparam(pthread_self(), &policy, ¶m); if (s != 0) errc(EXIT_FAILURE, s, "pthread_getschedparam"); \& printf("%s\[rs]n", msg); display_sched_attr(policy, ¶m); } \& static void * thread_start(void *arg) { display_thread_sched_attr("Scheduler attributes of new thread"); \& return NULL; } \& int main(int argc, char *argv[]) { int s, opt, inheritsched, use_null_attrib, policy; pthread_t thread; pthread_attr_t attr; pthread_attr_t *attrp; char *attr_sched_str, *main_sched_str, *inheritsched_str; struct sched_param param; \& /* Process command\-line options. */ \& use_null_attrib = 0; attr_sched_str = NULL; main_sched_str = NULL; inheritsched_str = NULL; \& while ((opt = getopt(argc, argv, "a:Ai:m:")) != \-1) { switch (opt) { case \[aq]a\[aq]: attr_sched_str = optarg; break; case \[aq]A\[aq]: use_null_attrib = 1; break; case \[aq]i\[aq]: inheritsched_str = optarg; break; case \[aq]m\[aq]: main_sched_str = optarg; break; default: usage(argv[0], "Unrecognized option\[rs]n"); } } \& if (use_null_attrib && (inheritsched_str != NULL || attr_sched_str != NULL)) { usage(argv[0], "Can\[aq]t specify \-A with \-i or \-a\[rs]n"); } \& /* Optionally set scheduling attributes of main thread, and display the attributes. */ \& if (main_sched_str != NULL) { if (!get_policy(main_sched_str[0], &policy)) usage(argv[0], "Bad policy for main thread (\-m)\[rs]n"); param.sched_priority = strtol(&main_sched_str[1], NULL, 0); \& s = pthread_setschedparam(pthread_self(), policy, ¶m); if (s != 0) errc(EXIT_FAILURE, s, "pthread_setschedparam"); } \& display_thread_sched_attr("Scheduler settings of main thread"); printf("\[rs]n"); \& /* Initialize thread attributes object according to options. */ \& attrp = NULL; \& if (!use_null_attrib) { s = pthread_attr_init(&attr); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_init"); attrp = &attr; } \& if (inheritsched_str != NULL) { if (inheritsched_str[0] == \[aq]e\[aq]) inheritsched = PTHREAD_EXPLICIT_SCHED; else if (inheritsched_str[0] == \[aq]i\[aq]) inheritsched = PTHREAD_INHERIT_SCHED; else usage(argv[0], "Value for \-i must be \[aq]e\[aq] or \[aq]i\[aq]\[rs]n"); \& s = pthread_attr_setinheritsched(&attr, inheritsched); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_setinheritsched"); } \& if (attr_sched_str != NULL) { if (!get_policy(attr_sched_str[0], &policy)) usage(argv[0], "Bad policy for \[aq]attr\[aq] (\-a)\[rs]n"); param.sched_priority = strtol(&attr_sched_str[1], NULL, 0); \& s = pthread_attr_setschedpolicy(&attr, policy); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_setschedpolicy"); s = pthread_attr_setschedparam(&attr, ¶m); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_setschedparam"); } \& /* If we initialized a thread attributes object, display the scheduling attributes that were set in the object. */ \& if (attrp != NULL) { s = pthread_attr_getschedparam(&attr, ¶m); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_getschedparam"); s = pthread_attr_getschedpolicy(&attr, &policy); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_getschedpolicy"); \& printf("Scheduler settings in \[aq]attr\[aq]\[rs]n"); display_sched_attr(policy, ¶m); \& pthread_attr_getinheritsched(&attr, &inheritsched); printf(" inheritsched is %s\[rs]n", (inheritsched == PTHREAD_INHERIT_SCHED) ? "INHERIT" : (inheritsched == PTHREAD_EXPLICIT_SCHED) ? "EXPLICIT" : "???"); printf("\[rs]n"); } \& /* Create a thread that will display its scheduling attributes. */ \& s = pthread_create(&thread, attrp, &thread_start, NULL); if (s != 0) errc(EXIT_FAILURE, s, "pthread_create"); \& /* Destroy unneeded thread attributes object. */ \& if (!use_null_attrib) { s = pthread_attr_destroy(&attr); if (s != 0) errc(EXIT_FAILURE, s, "pthread_attr_destroy"); } \& s = pthread_join(thread, NULL); if (s != 0) errc(EXIT_FAILURE, s, "pthread_join"); \& exit(EXIT_SUCCESS); } .EE .\" SRC END .SH "انظر أيضًا" .ad l .nh \fBgetrlimit\fP(2), \fBsched_get_priority_min\fP(2), \fBpthread_attr_init\fP(3), \fBpthread_attr_setinheritsched\fP(3), \fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3), \fBpthread_create\fP(3), \fBpthread_self\fP(3), \fBpthread_setschedprio\fP(3), \fBpthreads\fP(7), \fBsched\fP(7) .PP .SH ترجمة تُرجمت هذه الصفحة من الدليل بواسطة زايد السعيدي . .PP هذه الترجمة هي وثيقة مجانية؛ راجع .UR https://www.gnu.org/licenses/gpl-3.0.html رخصة جنو العامة الإصدار 3 .UE أو ما بعده للاطلاع على شروط حقوق النشر. لا توجد أي ضمانات. .PP إذا وجدت أي أخطاء في ترجمة صفحة الدليل هذه، يرجى إرسال بريد إلكتروني إلى قائمة بريد المترجمين: .MT kde-l10n-ar@kde.org .ME .