__wake_up() in kernel 2.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I was  studying process management  but I found something  which seems
strange to  me.  In  particular  if we  refer  to  kernel 2.2.21  from
/usr/src/linux/include/sched.h we can read the following lines.

#define TASK_EXCLUSIVE          32
...

(First  question :  an  exclusive process  is  a process  that can  be
awakened  and when  it happens  no other  one should  be  awakened too
right? I saw in kernel 2.4.18 things changed a little)

#define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE 
						      | TASK_EXCLUSIVE)
#define  wake_up_interruptible(x)  __wake_up((x),TASK_INTERRUPTIBLE  |
					         TASK_EXCLUSIVE)

But when we refer to /usr/src/linux/kernel/sched.c we can read

void __wake_up(struct wait_queue **q, unsigned int mode)
{
        struct task_struct *p, *best_exclusive;
        struct wait_queue *head, *next;
        unsigned int do_exclusive;

        if (!q)
                goto out;
        /*
         * this is safe to be done before the check because it  
         * means no deference, just pointer operations.
         */
        head = WAIT_QUEUE_HEAD(q);

        read_lock(&waitqueue_lock);
        next = *q;
        if (!next)
                goto out_unlock;
        
        best_exclusive = 0;
        do_exclusive = mode & TASK_EXCLUSIVE;
        while (next != head) {
                p = next->task;
                next = next->next;
                if (p->state & mode) {
                        if (do_exclusive && p->task_exclusive) {
                                if (best_exclusive == NULL)

               best_exclusive = p;
                        }
                        else {
                                wake_up_process(p);  <--
                        }
                } 
        }
        if (best_exclusive)
                wake_up_process(best_exclusive);
out_unlock:
        read_unlock(&waitqueue_lock);
out:
        return;
}

Now it  seems to me very  strange considering that  __wake_up() can be
called only through the previous macros. Infact TASK_EXCLUSIVE in this
case should always be set. So what's the meaning of do_exclusive?
And then if  it's so I suppose wake_up_process(p)  I marked will never
be executed.

What's wrong in what I said?


Regards,

Angelo Dell'Aera 'buffer' 
<buffer@users.sourceforge.net>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux