2013年8月28日星期三

Only TASK_RUNNING process is scheduled to re-state what?

/ * Globalfifo read function * /
static ssize_t globalfifo_read (struct file * filp, char __ user * buf, size_t count,
loff_t * ppos)
{
int ret;
struct globalfifo_dev * dev = filp-> private_data;
DECLARE_WAITQUEUE (wait, current);

down (& dev-> sem); / * get semaphore * /
add_wait_queue (& dev-> r_wait, & wait); / * enter * read wait queue head /

/ * wait for the FIFO is not empty * /
if (dev-> current_len == 0) {
if (filp-> f_flags & O_NONBLOCK) {
ret = - EAGAIN;
goto out;
}
__set_current_state (TASK_INTERRUPTIBLE); / * process state changes in sleep * /
up (& dev-> sem);

schedule (); / * scheduling other process execution * /



above code by calling the schedule function allows the current process to sleep, other processes which can wake up function through wake_up, wake_up Why can wake it up it? Not to say that the process can only be re-scheduled state TASK_RUNNING what? Through this process the front __set_current_state (TASK_INTERRUPTIBLE) will set the process became TASK_INTERRUPTIBLE, scheduling should not ah?
------ Solution ---------------------------------------- ----
Well, for the time being so that you still remember it, you may not understand now Tieshanglai.
------ For reference only -------------------------------------- -
to the process set TASK_INTERRUPTIBLE, we do not want this process to be scheduled, waiting wake_up, in front wake_up will not be dispatched. Because wake_up wait before conditions are not ripe, so no progress was again dispatched. So to change state. wake_up status will be changed when running, do not worry.
------ For reference only -------------------------------------- -



wake_up This function sets TASK_RUNNING it? Does not seem right
------ For reference only ----------------------------------- ----
I read the source code, wake_up certainly will.
------ For reference only -------------------------------------- -


1. thats why i posted the code and there are sets state runinig, where no stickers
2. wake_up which can be posted the next set running state?

Thank you! !
------ For reference only ---------------------------------------




I can understand, just stick under it, thank you
There is, I posted the code behind why he has set as running state it? If wake_up will be set, and that I posted this code should be followed would not have set up ah? ? ?
------ For reference only -------------------------------------- -



pot, you're right, knot stickers

没有评论:

发表评论