由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - multithread question
相关主题
pthread_kill SIGINT SIG_DFL multithreadfile descriptor
Does Linux support thread?[转载] alarm, pause 又一问
multithread programmingA Unix question
Help needed, about pthread...does Linux has real time timer?
what is the difference between pthread and thr_ ?which shell is the best among csh, ksh, bsh?
openMP or boost::thread (pthread) for multithreading ?Perl Q
how to fork a subroutine in unix?async-signal safe 问题
[转载] shared library一问Socket programming help
相关话题的讨论汇总
话题: use话题: threads话题: sleep话题: thread
进入Unix版参与讨论
1 (共1页)
z***c
发帖数: 1
1
Hi, dear all:
after forking several threads, the main thread needs to
wait for some
time interval to continue.
1: I can not use Sleep() since it will make all threads
sleep.
2: when I use delay(), it needs another function to convert
seconds into ticks.
but when I compile it , it seems the compiler can not
reference to these functions, do I have to link it with some
libraries?
3: In some examples, I saw something like
pthread_deley_np(), but I cannot
find with man in my unix machine.
a
t******q
发帖数: 117
2
Hi,
why do you need to wait the time?
can you use a global variable setted by main and resetted by
the
thread, polling by the main thread.
1, you can use your own defined global variable
2, you can do that is use pthread_mutex.
3, another way is to use pthread_condattr_init to
synchronize the threads.
Suppose you do not need precise time just need the thread to
initilized. I use Linux
I use linux can not find delay.
I think you have to link the lib file too seems.
This is a RT_linux near_POSIX a
b*e
发帖数: 3845
3

I remember u can only fork child process. Threads are not
forked. So u can just use sleep in the main thread routine.
All done.

【在 z***c 的大作中提到】
: Hi, dear all:
: after forking several threads, the main thread needs to
: wait for some
: time interval to continue.
: 1: I can not use Sleep() since it will make all threads
: sleep.
: 2: when I use delay(), it needs another function to convert
: seconds into ticks.
: but when I compile it , it seems the compiler can not
: reference to these functions, do I have to link it with some

1 (共1页)
进入Unix版参与讨论
相关主题
Socket programming helpwhat is the difference between pthread and thr_ ?
a perl questionopenMP or boost::thread (pthread) for multithreading ?
多次遇到这种问题:previous declaration of .....how to fork a subroutine in unix?
Can I get the CPU-time of a thread?[转载] shared library一问
pthread_kill SIGINT SIG_DFL multithreadfile descriptor
Does Linux support thread?[转载] alarm, pause 又一问
multithread programmingA Unix question
Help needed, about pthread...does Linux has real time timer?
相关话题的讨论汇总
话题: use话题: threads话题: sleep话题: thread