Sponsored Content
Top Forums Programming How to sleep and wake a thread??? Post 302582581 by gabam on Friday 16th of December 2011 11:36:46 AM
Old 12-16-2011
Could you please write a small little program to show how these functions work, I beg you please!
Thanks!
 

7 More Discussions You Might Find Interesting

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

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

3. Programming

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... (0 Replies)
Discussion started by: cometeor
0 Replies

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

5. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

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

7. 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
cpipe(1)							Programmer's Manual							  cpipe(1)

NAME
cpipe - copy stdin to stdout while counting bytes and reporting progress SYNOPSIS
cpipe [-b bsize] [-vt] [-vr] [-vw] [-ngr] [-s speed] OPTIONS
-b buffer size in kB, 1 Int value between 1 and oo. Default: `128' -vt show throughput. -vr show read-times. -vw show write-times. -ngr non-greedy read. Don't enforce a full buffer on read before starting to write. -s throughput speed limit in kB/s, 1 Double value between 1 and oo. DESCRIPTION
Cpipe copies its standard input to its standard output while measuring the time it takes to read an input buffer and write an output buf- fer. If one or more of the -vx options is given, statistics of average throughput and the total amount of bytes copied are printed to the standard error output. Non Greedy Read Normally, cpipe does its best to totally fill its buffer (option -b) before it starts writing. In some situations however, e.g. if you talk to an interactive program via cpipe, this deadlocks the communication: said program waits for input which it will never see, because the input is stuck in cpipe's buffer. But cpipe itself will not see more input before the program does not respond. To get around this, try using -ngr. When issuing a read call, cpipe is then satisfied as soon as it gets at least one byte. Instead of filling the buffer, it stops reading and writes whatever it got to the output. Note, however, that the throughput measurements will be less exact if the number of bytes transferred in one read/write pair becomes small, because cpipe will spent relatively more time working on every byte. Limiting Throughput If a throughput limit is specified with option -s, cpipe calls usleep(3) in between copying buffers, thereby artificially extending the duration of a read/write-cycle. Since on most systems there is a certain minimum time usleep() sleeps, e.g. 0.01s, it is impossible to reach high limits with a small buffer size. In this case increasing the buffer size (option -b) might help. However, keep in mind that this limits the throughput only on the average. Every single buffer is copied as fast as possible. EXAMPLE
The command tar cCf / - usr | cpipe -vr -vw -vt > /dev/null results in an output like ... in: 19.541ms at 6.4MB/s ( 4.7MB/s avg) 2.0MB out: 0.004ms at 30.5GB/s ( 27.1GB/s avg) 2.0MB thru: 19.865ms at 6.3MB/s ( 4.6MB/s avg) 2.0MB ... The first column shows the times it takes to handle one buffer of data (128kB by default). The read-call took 19.541ms, the write-call to /dev/null took just 0.004ms and from the start of the read to the end of write, it took 19.865ms. The second column shows the result of dividing the buffer size (128kB by default) by the times in the first column. The third column contains the average over all measured values from the start of the program. Finally, the last column shows the total number of bytes transferred, which is of course the same for reading and writing. BUGS
This program uses precious processor cycles. Consequently the measured times will be different from the transfer rates possible without it. Instead of just non-greedy reading, full non-blocking I/O and use of select(2) should be used to make sure that no deadlocks occur when communicating with interactive programs. CREDITS
Peter Astrand <astrand@lysator.liu.se> recommended the speed limit. Ivo De Decker <ivo@zeus.rug.ac.be> asked for deadlock prevention, which is (hopefully) sufficiently covered by the non-greedy read. AUTHOR
Bug reports, beer and postcards go to pifpafpuf@gmx.de. New versions will show up on http://cpipe.berlios.de/. Clig-manuals 3.0.0 cpipe(1)
All times are GMT -4. The time now is 09:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy