3

In the Linux Kernel I am putting a task asleep with

set_current_state(TASK_INTERRUPTIBLE);
schedule_hrtimeout(&next_release_time, HRTIMER_MODE_ABS);

That works so far. The documentation says:

/* %TASK_INTERRUPTIBLE - the routine may return early if a signal is
 * delivered to the current task or the current task is explicitly woken
 * up.

So I was assuming calling

wake_up_process(task);

Would let the routine return. At this point I am not calling from the current task. Precisley I am looping over a list, that holds all tasks, that require a wake up.

   list_for_each(pos, &my_obj_list){
        obj = list_entry(pos, struct my_obj, my_obj_list);
        wake_up_process(obj->task);
    }

However, this just lets the kernel crash when it gets there. So I guess this is not the way how the function should be used.

Do you have any ideas or hints regarding this problem?

pixy
  • 66
  • 5
  • 1
    So `all_list` is something you have added to `struct task_struct`? – Ian Abbott Apr 25 '19 at 16:56
  • I was showing a simplified example. Indeed my local struct `struct reservation` has a pointer to the task. I edited the question. – pixy Apr 26 '19 at 07:41
  • I suspect the crash is probably related to unsafe list handling. When are things added to and removed from the list, and does it use a spin-lock? – Ian Abbott Apr 26 '19 at 10:23
  • In the initilization entrys are added to the list, this should not interfere with a wake up call. So you are saying calling wake_up_process is the right way to wake up the task? Since I don't exactly understand the meaning of "may return early if a signal is delivered to the current task". – pixy Apr 26 '19 at 12:22
  • 1
    I don't recall ever using `wake_up_process` myself, although the documentation for `schedule_hrtimeout` mentions its use with `TASK_UNINTERRUPTIBLE`, so I guess it should be fine when used with `TASK_INTERRUPTIBLE` also. – Ian Abbott Apr 26 '19 at 14:19
  • What would be the best practice to wake up the tasks with a signal? Since it's explicitly mentioned i think this would be the best way to go if the task state is TASK_INTERRUPTIBLE – pixy May 23 '19 at 13:05

0 Answers0