query about schedule.

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

 



Hi,

I have the following piece of code which is written for a device read
file_operation, I want a process to block till a packet queue becomes
non-zero in length...

.
.
.
set_current_state (TASK_INTERRUPTIBLE);
for (;!skb_queue_len (&p->pkt_queue);) {
	schedule ();
	if (signal_pending (current)) {
		/* ouch! another doubt */
		rv = -ERESTARTSYS;
		goto ret;
	}
}
.
.
.
ret:
	set_current_state (TASK_RUNNING);
	schedule ();
	return rv;
}
.
.
.

I want to know the following:

1. does schedule return immediately, or blocks by shifting
CPU attention to another process (because we are not TASK_RUNNING)

2. if not, does this mean a busy wait

3. when schedule returns, are we TASK_RUNNING

Please comment on the above code.

Since I ensure that only one process will be waiting on a particular
queue, I do not want to use a wait queue.

Thanks in advance

--
Sudeep


--
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