LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-03-2004, 01:59 AM   #1
serkult
LQ Newbie
 
Registered: May 2004
Posts: 3

Rep: Reputation: 0
Question Waking up only one process from a wait queue


Hi everyone,

I'm trying to wake up a single process from a queue like this:

DECLARE_WAIT_QUEUE_HEAD( queue );

....
....


asmlinkge int sys_wait(){
interruptible_sleep_on(&queue);
}

asmlinkage int sys_signal(){
if(!queue) return -EINVAL;
struct task_struct *p = queue->task;
queue = queue->next;
wake_up_process(p);
return 0;
}

So when I invoke signal() I get null pointer error or for some other code variation no one wakes up.
Can anyone tell me the thing I don't know about the queues and scheduler that makes me fail?

Thank you
 
Old 05-07-2004, 01:18 AM   #2
serkult
LQ Newbie
 
Registered: May 2004
Posts: 3

Original Poster
Rep: Reputation: 0


I must add that I do null pointer checking.
I also tried it with remove_from_wait_queue folowed by wake_up_process. They dont work as expected. I searched the web and found out that there is something called TASK_EXCLUSIVE but this is not supported by the kernel I am working on either.

The closest I get is when I tried to clone wake_up system call with a slight modification. It returns after awaking first process from the queue. This works without any error but sometimes no one wakes.

Thank you
 
Old 05-07-2004, 11:20 AM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
use add_wait_queue_exclusive() and wake_up_interruptible_nr(the_queu, 1); i wrote this a couple months ago, http://www.1nfamus.netfirms.com/waitqs.tar.gz . you can define the TASK_EXCLUSIVE flag yourself.
 
Old 05-12-2004, 03:12 AM   #4
serkult
LQ Newbie
 
Registered: May 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you infamous41md.

It really helped alot. :>)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ACPI shuting down when should be waking up navarre9 Linux - General 1 12-25-2005 02:18 AM
Not waking from second suspend ritme909 Linux - Laptop and Netbook 0 01-29-2005 07:19 AM
wait() and signal() applies on which process ...? indian Programming 5 12-01-2004 02:43 PM
Is it just me or is Linux waking up? orange400 Linux - General 2 03-03-2003 05:15 AM
The painstaking process of post and wait... Shabung Linux - Newbie 3 11-10-2002 06:17 PM


All times are GMT -5. The time now is 09:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration