...

View Full Version : pthreads - messages



tricolaire
09-21-2007, 03:37 AM
Hi, I'm writing an executable in c that needs to have an idea of time.

I know about the time.h header, but my issue stems from needing to monitor time at the same time as other things are going on.

I have an inkling that threads are involved here.

I have spent literally the last two hours on google and have amassed a basic understanding of pthreads - how to create and use them - but I don't know how I can use one thread to tell another thread to stop doing something, without ending the entire program.

Can someone please either show me how to do this or point me to a place that can?

TIA

P.S. here is the general idea of flow that I'm going for, in pseudo-code of course:


main_thread {

create_thread
start_thread_action | start_main_thread_action
if_second_thread_says_so{
main_thread_stops_action_and_continues_with_the_rest_of_the_program
}

}

tricolaire
09-22-2007, 03:06 AM
ok, the question has changed

I need to know how to kill a pthread before it has finished its process.

I know about the function pthread_cancel, but that function isn't implemented in Mac OS X, or so I'm told, and the discussions I've found on this topic all pertain to how to do such a thing in very specific projects that have little to do with my own.

any help is greatly appreciated

Thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum