Hello,
I sort of believe that line #35 in the function below is redundant,
since:
1. The current->state is set to TASK_INTERRUPTIBLE in line #30 and
then schedule() is called. So the process will be blocked and this process
will be removed from runqueue. 2. After the schedule() called, the process
will have to get scheduled (put back to runqueue) again before it can reach
line#34. 3. In the current linux kernel (or 2.4.19 at least), the only way
to get this process back to kernel is calling try_to_wakeup().
Since try_to_wakeup() will set the task status to TASK_RUNNING anyway.
I don't understand why it's set again at line 35. That's why I say it's
redundant code. Am I right? Or do I miss something?
BTW, I am not just picky about the redundancy of one line of code. I
asked this question because some other reason.
http://lxr.linux.no/source/fs/pipe.c
27 void pipe_wait(struct inode * inode)
28 {
29 DECLARE_WAITQUEUE(wait, current);
30 current->state = TASK_INTERRUPTIBLE;
31 add_wait_queue(PIPE_WAIT(*inode), &wait);
32 up(PIPE_SEM(*inode));
33 schedule();
34 remove_wait_queue(PIPE_WAIT(*inode), &wait);
35 current->state = TASK_RUNNING;
36 down(PIPE_SEM(*inode));
37 }
thanks,
--
Haoqiang Zheng
Columbia University
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/