pausing a thread in Unix

Post questions regarding programming in C/C++ in Linux/Unix.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

pausing a thread in Unix

Postby Krusty » Wed Sep 24, 2003 12:55 pm

I'm working with pthreads in Unix/Linux. I'm looking for a way to make just a single thread sleep. (Sleep() affects the whole process.) I found some references to pthread_delay_np() online, but it seems my system doesn't support this. Any other suggestions?
Krusty
 

Postby Alvaro » Wed Sep 24, 2003 1:59 pm

You can use this:

Code: Select all
#include <sys/time.h>

struct timeval timeout = {2, 500000}; // {seconds, microseconds}
select(0, NULL, NULL, NULL, &timeout);
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

condition variables

Postby devil_slayer » Wed Oct 01, 2003 3:49 am

User avatar
devil_slayer
 
Posts: 489
Joined: Wed Oct 01, 2003 3:44 am
Location: Warsaw, POLAND


Return to Unix/Linux

Who is online

Users browsing this forum: No registered users and 1 guest