how to wake up a thread that blocking at epoll_wait?


 
Thread Tools Search this Thread
Top Forums Programming how to wake up a thread that blocking at epoll_wait?
# 1  
Old 12-14-2008
how to wake up a thread that blocking at epoll_wait?

I have two threads: one maintains a thread-safe message queue (handle this queue at the beginning of every loop) and deals with tcp connections, the other one posts message to the former one. the problem is, while the former one was blocking at epoll_wait, it's not sure that how long until the posted message be handled. So I want to wakeup the blocking thread when posting message to it.
Any suggestion?
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Computer wake commands

I'm a OS X user (MacBook Pro, OS X Lion) and I need it to wake up on Mondays, Wednesdays, Thursdays and Saturdays at 9:00 AM on the rest of the days of the week at 7:00 I issue the following commands: sudo pmset repeat wake MWRS 09:00:00 for the former sudo pmset repeat wake TFU... (1 Reply)
Discussion started by: scrutinizerix
1 Replies

2. Programming

Which are blocking and non-blocking api's in sockets in C ?

among the below socket programming api's, please let me know which are blocking and non-blocking. socket accept bind listen write read close (2 Replies)
Discussion started by: VSSajjan
2 Replies

3. UNIX for Dummies Questions & Answers

Trouble Configuring Wake On Lan

As the title implies I'm having trouble setting up Wake-On-LAN with my Debian box. Here is the output from ethtool and my /etc/network/interfaces: # cat /etc/network/interfaces # /etc/network/interfaces - configuration file for ifup(8), ifdown(8) # The loopback interface auto lo iface lo... (2 Replies)
Discussion started by: Azrael
2 Replies

4. Programming

How to sleep and wake a thread???

Hi guys, I am creating two posix threads. I have some queries, hopefully you will help me out with them 1) How can I put a thread to indefinite sleep, for indefinite time period. I am familiar with this sleep(5); for 5 second, how can I make it indefinite?? 2) How can one thread wake another... (11 Replies)
Discussion started by: gabam
11 Replies

5. UNIX for Dummies Questions & Answers

Linux Device Driver: how can an ISR wake up a user-thread?

Hi all, Is it possible to do the following in Linux (kernel 2.6.x): - A user-space thread goes to "sleep". Using any call/mechanism - On a hardware generated interrupt, the Interrupt handler (ISR) "wakes" the sleeping user-thread. I have seen wait_event() and wake_up() but it appears... (1 Reply)
Discussion started by: agaurav
1 Replies

6. UNIX for Advanced & Expert Users

wake up user space thread from kernel space ISR

Hello, I'm searching for a proper way to let the kernel space ISR(implemented in a kernel module) wake up a user space thread on a hardware interrupt. Except for sending a real-time signal, is it possible to use a semaphore? I've searched it on google, but it seems impossible to share a... (0 Replies)
Discussion started by: aaronwong
0 Replies

7. Shell Programming and Scripting

Wake on LAN script

m old to Unix but new to scripting I have a MacBook running osx that I want to use as an nfs client. The server will be a linux box with a wake on lan card. Here's the idea. Run a cron command on the mac every minute that checks if I am on my home wireless network (the linux box is wired to... (6 Replies)
Discussion started by: anon0mus
6 Replies

8. UNIX for Advanced & Expert Users

Wake on Lan script

Im old to Unix but new to scripting I have a MacBook running osx that I want to use as an nfs client. The server will be a linux box with a wake on lan card. Here's the idea. Run a cron command on the mac every minute that checks if I am on my home wireless network (the linux box is wired to... (0 Replies)
Discussion started by: anon0mus
0 Replies
Login or Register to Ask a Question
Thread::Queue(3pm)					 Perl Programmers Reference Guide					Thread::Queue(3pm)

NAME
Thread::Queue - thread-safe queues SYNOPSIS
use Thread::Queue; my $q = new Thread::Queue; $q->enqueue("foo", "bar"); my $foo = $q->dequeue; # The "bar" is still in the queue. my $foo = $q->dequeue_nb; # returns "bar", or undef if the queue was empty my $left = $q->pending; # returns the number of items still in the queue DESCRIPTION
A queue, as implemented by "Thread::Queue" is a thread-safe data structure much like a list. Any number of threads can safely add elements to the end of the list, or remove elements from the head of the list. (Queues don't permit adding or removing elements from the middle of the list). FUNCTIONS AND METHODS
new The "new" function creates a new empty queue. enqueue LIST The "enqueue" method adds a list of scalars on to the end of the queue. The queue will grow as needed to accommodate the list. dequeue The "dequeue" method removes a scalar from the head of the queue and returns it. If the queue is currently empty, "dequeue" will block the thread until another thread "enqueue"s a scalar. dequeue_nb The "dequeue_nb" method, like the "dequeue" method, removes a scalar from the head of the queue and returns it. Unlike "dequeue", though, "dequeue_nb" won't block if the queue is empty, instead returning "undef". pending The "pending" method returns the number of items still in the queue. SEE ALSO
threads, threads::shared perl v5.8.0 2002-06-01 Thread::Queue(3pm)