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
thr_join(3C)						   Standard C Library Functions 					      thr_join(3C)

NAME
thr_join - wait for thread termination SYNOPSIS
cc -mt [ flag... ] file...[ library... ] #include <thread.h> int thr_join(thread_t thread, thread_t *departed, void **status); DESCRIPTION
The thr_join() function suspends processing of the calling thread until the target thread completes. The thread argument must be a member of the current process and cannot be a detached thread. See thr_create(3C). If two or more threads wait for the same thread to complete, all will suspend processing until the thread has terminated, and then one thread will return successfully and the others will return with an error of ESRCH. The thr_join() function will not block processing of the calling thread if the target thread has already terminated. If a thr_join() call returns successfully with a non-null status argument, the value passed to thr_exit(3C) by the terminating thread will be placed in the location referenced by status. If the target thread ID is 0, thr_join() finds and returns the status of a terminated undetached thread in the process. If no such thread exists, it suspends processing of the calling thread until a thread for which no other thread is waiting enters that state, at which time it returns successfully, or until all other threads in the process are either daemon threads or threads waiting in thr_join(), in which case it returns EDEADLK. See NOTES. If departed is not NULL, it points to a location that is set to the ID of the terminated thread if thr_join() returns successfully. RETURN VALUES
If successful, thr_join() returns 0. Otherwise, an error number is returned to indicate the error. ERRORS
EDEADLK A joining deadlock would occur, such as when a thread attempts to wait for itself, or the calling thread is waiting for any thread to exit and only daemon threads or waiting threads exist in the process. ESRCH No undetached thread could be found corresponding to the given thread ID. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
thr_create(3C), thr_exit(3C), wait(3C), attributes(5), standards(5) NOTES
Using thr_join(3C) in the following syntax, while (thr_join(0, NULL, NULL) == 0); will wait for the termination of all non-daemon threads, excluding threads that are themselves waiting in thr_join(). SunOS 5.11 27 Mar 2000 thr_join(3C)