set_current_state() use in loops confusion

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

 



Hi !

 Noticed that in a number of cases - often while(!kthread_should_stop()){ loops
 the call to set_current_state(...) is inside the loop - but e.g. in the below
 case why would that be needed ? schedule() is not changing the state visibly
 for the loop - so what is the point of setting the state inside the loop ?

e.g. net/core/pktgen.c
        /* Wait for kthread_stop */
        while (!kthread_should_stop()) {
                set_current_state(TASK_INTERRUPTIBLE);
                schedule();
        }

from code review it seems to be that this would be equivalent

        set_current_state(TASK_INTERRUPTIBLE);
        while (!kthread_should_stop()) {
                schedule();
        }

what did I miss ?

thx!
hofrat

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[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