Quick pthread question - starting paused/suspended

This is a discussion on Quick pthread question - starting paused/suspended within the C Programming forums, part of the General Programming Boards category; Hey, Is there an easy way to create a thread in a suspended/paused state and the resume it later..? I ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4

    Quick pthread question - starting paused/suspended

    Hey,

    Is there an easy way to create a thread in a suspended/paused state and the resume it later..?

    I mean I could use a lock/sems... But is there a "nicer" way?

    Cheers.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,660
    There is no suspend/resume interface. You have to use blocking primitives.

    gg

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4
    Yeah thats what I thought... Done that and it seems to work... Thanks for your help.

    Quick one... Pthreads & signals - what happens if I send SIGSTOP to a thread using pthread_kill()? Will it halt the whole process or just that thread???

    Also is there a pthread equivalent of waitpid()? I.e. can I setup to wait until a thread Rxes a signal (say sigstop) and is in a halt state etc..?


    Cheers,

    NW

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,660
    >> Will it halt the whole process or just that thread?
    Still affects the process. pthread_kill just lets you control which thread will handle the signal.

    >> pthread equivalent of waitpid()?
    You can call pthread_join (on an attached thread) to wait for a thread to exit.

    >> I setup to wait until a thread Rxes a signal (say sigstop) and is in a halt state etc..?
    Well, you could certainly use signals to communicate with your threads.

    Here's the 2004 Posix specification: http://www.opengroup.org/onlinepubs/009695399/toc.htm

    The pthread_sigmask page has example code for signal polling in a thread.

    Here's what Posix has to say on "signal concepts": http://www.opengroup.org/onlinepubs/...chap02_04.html

    For completeness, here's the 2008 Posix spec: http://www.opengroup.org/onlinepubs/9699919799/toc.htm

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  2. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  3. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  4. Quick Question on File Names and Directories
    By Kyoto Oshiro in forum C++ Programming
    Replies: 4
    Last Post: 03-29-2002, 01:54 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21