diff options
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r-- | litmus/litmus.c | 109 |
1 files changed, 87 insertions, 22 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c index 81384327e850..2300281b6b30 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -290,6 +290,60 @@ asmlinkage long sys_null_call(cycles_t __user *ts) | |||
290 | return ret; | 290 | return ret; |
291 | } | 291 | } |
292 | 292 | ||
293 | |||
294 | |||
295 | |||
296 | |||
297 | |||
298 | |||
299 | |||
300 | |||
301 | |||
302 | long __litmus_admit_task(struct task_struct* tsk); | ||
303 | |||
304 | asmlinkage long sys_slave_non_rt_threads(void) | ||
305 | { | ||
306 | long retval = 0; | ||
307 | struct task_struct *leader = current->group_leader; | ||
308 | struct task_struct *t; | ||
309 | struct task_struct *hp = NULL; | ||
310 | |||
311 | read_lock_irq(&tasklist_lock); | ||
312 | |||
313 | is_realtime(target) | ||
314 | |||
315 | t = leader; | ||
316 | do { | ||
317 | TRACE_CUR("threads in %s/%d: %s/%d:\n", leader->comm, leader->pid, t->comm, t->pid); | ||
318 | |||
319 | if (tsk_rt(t)->heap_node == NULL) { | ||
320 | retval = __litmus_admit_task(t); | ||
321 | |||
322 | if (retval != 0) break; | ||
323 | |||
324 | /* hasn't been admitted into rt. make it a slave. */ | ||
325 | tsk_rt(t)->slave = 1; | ||
326 | } | ||
327 | else if (is_realtime(t)) | ||
328 | if (litmus->compare(t, hp)) { | ||
329 | hp = t; | ||
330 | } | ||
331 | } | ||
332 | |||
333 | t = next_thread(t); | ||
334 | } while(t != leader); | ||
335 | |||
336 | if (hp) { | ||
337 | /* set up inheritance */ | ||
338 | |||
339 | } | ||
340 | |||
341 | read_unlock_irq(&tasklist_lock); | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | |||
293 | /* p is a real-time task. Re-init its state as a best-effort task. */ | 347 | /* p is a real-time task. Re-init its state as a best-effort task. */ |
294 | static void reinit_litmus_state(struct task_struct* p, int restore) | 348 | static void reinit_litmus_state(struct task_struct* p, int restore) |
295 | { | 349 | { |
@@ -318,32 +372,11 @@ static void reinit_litmus_state(struct task_struct* p, int restore) | |||
318 | } | 372 | } |
319 | } | 373 | } |
320 | 374 | ||
321 | long litmus_admit_task(struct task_struct* tsk) | 375 | long __litmus_admit_task(struct task_struct* tsk) |
322 | { | 376 | { |
323 | long retval = 0; | 377 | long retval = 0; |
324 | unsigned long flags; | 378 | unsigned long flags; |
325 | 379 | ||
326 | BUG_ON(is_realtime(tsk)); | ||
327 | |||
328 | if (get_rt_relative_deadline(tsk) == 0 || | ||
329 | get_exec_cost(tsk) > | ||
330 | min(get_rt_relative_deadline(tsk), get_rt_period(tsk)) ) { | ||
331 | TRACE_TASK(tsk, | ||
332 | "litmus admit: invalid task parameters " | ||
333 | "(e = %lu, p = %lu, d = %lu)\n", | ||
334 | get_exec_cost(tsk), get_rt_period(tsk), | ||
335 | get_rt_relative_deadline(tsk)); | ||
336 | retval = -EINVAL; | ||
337 | goto out; | ||
338 | } | ||
339 | |||
340 | if (!cpu_online(get_partition(tsk))) { | ||
341 | TRACE_TASK(tsk, "litmus admit: cpu %d is not online\n", | ||
342 | get_partition(tsk)); | ||
343 | retval = -EINVAL; | ||
344 | goto out; | ||
345 | } | ||
346 | |||
347 | INIT_LIST_HEAD(&tsk_rt(tsk)->list); | 380 | INIT_LIST_HEAD(&tsk_rt(tsk)->list); |
348 | 381 | ||
349 | /* avoid scheduler plugin changing underneath us */ | 382 | /* avoid scheduler plugin changing underneath us */ |
@@ -375,6 +408,38 @@ long litmus_admit_task(struct task_struct* tsk) | |||
375 | 408 | ||
376 | out_unlock: | 409 | out_unlock: |
377 | raw_spin_unlock_irqrestore(&task_transition_lock, flags); | 410 | raw_spin_unlock_irqrestore(&task_transition_lock, flags); |
411 | |||
412 | return retval; | ||
413 | } | ||
414 | |||
415 | long litmus_admit_task(struct task_struct* tsk) | ||
416 | { | ||
417 | long retval = 0; | ||
418 | unsigned long flags; | ||
419 | |||
420 | BUG_ON(is_realtime(tsk)); | ||
421 | |||
422 | if (get_rt_relative_deadline(tsk) == 0 || | ||
423 | get_exec_cost(tsk) > | ||
424 | min(get_rt_relative_deadline(tsk), get_rt_period(tsk)) ) { | ||
425 | TRACE_TASK(tsk, | ||
426 | "litmus admit: invalid task parameters " | ||
427 | "(e = %lu, p = %lu, d = %lu)\n", | ||
428 | get_exec_cost(tsk), get_rt_period(tsk), | ||
429 | get_rt_relative_deadline(tsk)); | ||
430 | retval = -EINVAL; | ||
431 | goto out; | ||
432 | } | ||
433 | |||
434 | if (!cpu_online(get_partition(tsk))) { | ||
435 | TRACE_TASK(tsk, "litmus admit: cpu %d is not online\n", | ||
436 | get_partition(tsk)); | ||
437 | retval = -EINVAL; | ||
438 | goto out; | ||
439 | } | ||
440 | |||
441 | retval = __litmus_admit_task(tsk); | ||
442 | |||
378 | out: | 443 | out: |
379 | return retval; | 444 | return retval; |
380 | } | 445 | } |