summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2013-06-01 16:36:48 +0200
committerRichard Braun <rbraun@sceen.net>2013-06-01 16:36:48 +0200
commit716a81ecd8b8e4dc23f04ff2a1d2c4ae8ace0f49 (patch)
tree64bf28f9d2425e474aba65cdb05cfb3e4ee37dd0 /kern/thread.c
parent0ce715c716f0510d9ec2d5a56dec4cbcfbd9522e (diff)
kern/thread: update creation attributes handling
Make passing attributes and passing a thread name mandatory.
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/kern/thread.c b/kern/thread.c
index 648f8ca1..7affc2d8 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -241,14 +241,6 @@ static unsigned char thread_policy_table[THREAD_NR_SCHED_POLICIES];
*/
static struct thread_sched_ops thread_sched_ops[THREAD_NR_SCHED_CLASSES];
-static struct thread_attr thread_default_attr = {
- NULL,
- NULL,
- THREAD_SCHED_POLICY_TS,
- THREAD_SCHED_TS_PRIO_DEFAULT,
- NULL
-};
-
/*
* Map of run queues for which a processor is running.
*/
@@ -1426,19 +1418,11 @@ thread_init(struct thread *thread, void *stack, const struct thread_attr *attr,
struct thread *caller;
struct task *task;
struct cpumap *cpumap;
- const char *name;
caller = thread_self();
- if (attr == NULL)
- attr = &thread_default_attr;
-
task = (attr->task == NULL) ? caller->task : attr->task;
- assert(task != NULL);
- name = (attr->name == NULL) ? task->name : attr->name;
- assert(name != NULL);
cpumap = (attr->cpumap == NULL) ? &caller->cpumap : attr->cpumap;
- assert(cpumap != NULL);
assert(attr->policy < THREAD_NR_SCHED_POLICIES);
/*
@@ -1463,7 +1447,7 @@ thread_init(struct thread *thread, void *stack, const struct thread_attr *attr,
thread_init_sched(thread, attr->priority);
thread->task = task;
thread->stack = stack;
- strlcpy(thread->name, name, sizeof(thread->name));
+ strlcpy(thread->name, attr->name, sizeof(thread->name));
thread->fn = fn;
thread->arg = arg;
@@ -1552,11 +1536,11 @@ thread_setup_reaper(void)
condition_init(&thread_reap_condition);
list_init(&thread_reap_list);
- attr.task = NULL;
attr.name = "x15_thread_reap";
+ attr.cpumap = NULL;
+ attr.task = NULL;
attr.policy = THREAD_SCHED_POLICY_TS;
attr.priority = THREAD_SCHED_TS_PRIO_DEFAULT;
- attr.cpumap = NULL;
error = thread_create(&thread, &attr, thread_reap, NULL);
if (error)
@@ -1627,11 +1611,11 @@ thread_setup_balancer(struct thread_runq *runq)
cpumap_zero(cpumap);
cpumap_set(cpumap, thread_runq_id(runq));
snprintf(name, sizeof(name), "x15_thread_balance/%u", thread_runq_id(runq));
- attr.task = NULL;
attr.name = name;
+ attr.cpumap = cpumap;
+ attr.task = NULL;
attr.policy = THREAD_SCHED_POLICY_RR;
attr.priority = THREAD_SCHED_RT_PRIO_MIN;
- attr.cpumap = cpumap;
error = thread_create(&balancer, &attr, thread_balance, runq);
cpumap_destroy(cpumap);
@@ -1698,10 +1682,10 @@ thread_setup_idler(struct thread_runq *runq)
panic("thread: unable to allocate idler thread stack");
snprintf(name, sizeof(name), "x15_thread_idle/%u", thread_runq_id(runq));
- attr.task = kernel_task;
attr.name = name;
- attr.policy = THREAD_SCHED_POLICY_IDLE;
attr.cpumap = cpumap;
+ attr.task = NULL;
+ attr.policy = THREAD_SCHED_POLICY_IDLE;
thread_init(idler, stack, &attr, thread_idle, runq);
cpumap_destroy(cpumap);