Because I maintain this FAQ with blogging software, the most recently edited item tends to float to the top. If you want to browse a table of contents in “semi-sane†order, here it is.
You can find very good discounts here, although some Fridays you can really get
lucky and make off like an Amazon bandit – I´ve seen discounts there as low as 75%
off sticker Price.
I am new to the subject of thread. Can someone tell me why is the average time that using pthread_create() to creat a thread is shorter than using fork() to create a process?
My thought is that because parent process has to wait for each child process. On the other hand, thr_create.c includes which only needs to wait for the last thread. Am I correct?
Threads are faster than a fork() because their overhead is much smaller, as they share the same memory space than their creator. This is why it takes about 30 times less time to create a pthread than fork the current process.
As for the parent waiting for the children to terminate, it’s up to you. If you create your threads “detached”, they will liberate their own memory space automatically as they terminate. Otherwise, you have to join in order for the threads to return their memory to the heap cleanly.
Hey i have a question, if i am using pthreads, each of them perform a function, these functions need to be executed in a cylcle…. but the pthread dies everytime the cycle starts, how do i keep my thread alive??
I want to execute a thread after some specific time only…lets say 10 to 15 seconds. SLEEP is not workint… it suspends whole program… I want to suspend thread only…
Is there any way out for that?
p.s: Time granularity and accuracy doesn’t matters a much.
hi ,
thanks
how i know if a thread finish?
There’s one special secret Sale link on Amazon:
http://tinyurl.com/2r7ldr
This is open every Friday and ONLY on Fridays!
You can find very good discounts here, although some Fridays you can really get
lucky and make off like an Amazon bandit – I´ve seen discounts there as low as 75%
off sticker Price.
Hey there
I am new to the subject of thread. Can someone tell me why is the average time that using pthread_create() to creat a thread is shorter than using fork() to create a process?
My thought is that because parent process has to wait for each child process. On the other hand, thr_create.c includes which only needs to wait for the last thread. Am I correct?
Hi Benson,
Threads are faster than a fork() because their overhead is much smaller, as they share the same memory space than their creator. This is why it takes about 30 times less time to create a pthread than fork the current process.
As for the parent waiting for the children to terminate, it’s up to you. If you create your threads “detached”, they will liberate their own memory space automatically as they terminate. Otherwise, you have to join in order for the threads to return their memory to the heap cleanly.
Hey i have a question, if i am using pthreads, each of them perform a function, these functions need to be executed in a cylcle…. but the pthread dies everytime the cycle starts, how do i keep my thread alive??
Hi…
I want to execute a thread after some specific time only…lets say 10 to 15 seconds. SLEEP is not workint… it suspends whole program… I want to suspend thread only…
Is there any way out for that?
p.s: Time granularity and accuracy doesn’t matters a much.