Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    PA
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    pthreads - messages

    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:

    Code:
    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   
       }
    
    }

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    PA
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ending a thread

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •