原创 线程调度 sched_param

2010-6-27 19:06 3778 5 5 分类: MCU/ 嵌入式

转自:http://china.qnx.com/developers/docs/6.4.1/neutrino/lib_ref/s/sched_param.html

sched_param





Structure that describes scheduling parameters




Synopsis:


#include <sched.h>

struct sched_param {
int32_t sched_priority;
int32_t sched_curpriority;
union {
int32_t reserved[8];
struct {
int32_t __ss_low_priority;
int32_t __ss_max_repl;
struct timespec __ss_repl_period;
struct timespec __ss_init_budget;
} __ss;
} __ss_un;
}

#define sched_ss_low_priority __ss_un.__ss.__ss_low_priority
#define sched_ss_max_repl __ss_un.__ss.__ss_max_repl
#define sched_ss_repl_period __ss_un.__ss.__ss_repl_period
#define sched_ss_init_budget __ss_un.__ss.__ss_init_budget



Description:





You'll use the sched_param structure when you get
or set the
scheduling parameters for a thread or process.


You can use these functions to get the scheduling parameters:



You can use these functions to set the scheduling parameters:



The members of sched_param include:


sched_priority
When you get the scheduling parameters,
this member reflects the priority that was assigned to the thread or
process.
It doesn't reflect any temporary adjustments due to priority
inheritance.

When you set the scheduling parameters,
set this member to the priority that you want to use.
The priority must be between
the minimum and maximum values returned by
sched_get_priority_min()
and
sched_get_priority_max()
for the scheduling policy.

sched_curpriority
When you get the scheduling parameters, this member is set to the
priority that the thread or process is currently running at.
This is the value that the kernel uses when making scheduling
decisions.

When you set the scheduling parameters, this member is ignored.



The other members are used with sporadic scheduling. The
following #define directives create the POSIX
names that correspond to
those members and should be used instead of accessing members directly.


sched_ss_low_priority
The background or low priority for the thread that's executing.

sched_ss_max_repl
The maximum number of times a replenishment will be scheduled,
typically
because of a blocking operation.
After a thread has blocked this many times, it automatically drops to
the
low-priority level for the remainder of its execution until
its execution budget is replenished.

sched_ss_repl_period
The time that should be used for scheduling the replenishment
of an execution budget after being blocked or having overrun the
maximum
number of replenishments.
This time is used as an offset against the time that a thread is made
READY.

sched_ss_init_budget
The time that should be used for the thread's execution budget.
As the thread runs at its high-priority level, its execution time is
carved
out of this budget.
Once the budget is entirely depleted, the thread drops to its
low-priority
level, where, if possible because of priority arrangements, it can
continue
to run until the execution budget is replenished.






Note:
  • The sched_priority must always be higher than
    sched_ss_low_priority.

  • The sched_ss_max_repl must be smaller than
    SS_REPL_MAX.


  • The sched_ss_init_budget must be larger than
    sched_ss_repl_period.


PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
5
关闭 站长推荐上一条 /3 下一条