[Q] Process Sleep

  • Another Unix question from "still trying to learn this newbie".

    Is there a preferred method of putting a process to sleep for a second
    or two? Basically I would like my process to block  for a specific
    period of time, even if it is the front process. The process is a Carbon
    app, but I don't really care whether the preferred method API is Carbon,
    BSD, POSIX, or Mach.

    Thanks.

    Rusty
  • On Friday, November 16, 2001, at 08:31  pm, Rusty Little wrote:

    > Is there a preferred method of putting a process to sleep for a second
    > or two? Basically I would like my process to block  for a specific
    > period of time, even if it is the front process. The process is a
    > Carbon app, but I don't really care whether the preferred method API is
    > Carbon, BSD, POSIX, or Mach.

    man 3 sleep, man usleep
    Why exactly do you want to do this, anyway? :-)

      -- Finlay
  • > Is there a preferred method of putting a process to sleep for a
    > second or two? Basically I would like my process to block  for a
    > specific period of time, even if it is the front process. The
    > process is a Carbon app, but I don't really care whether the
    > preferred method API is Carbon, BSD, POSIX, or Mach.

    The Carbon-way would be to use an event timer.  Look in
    CarbonEvents.h for InstallEventLoopTimer().

    -Ammon
    --
    Skidperfect Software            <http://www.skidperfect.com/>
  • >> Is there a preferred method of putting a process to sleep for a
    >> second or two? Basically I would like my process to block  for a
    >> specific period of time, even if it is the front process. The
    >> process is a Carbon app, but I don't really care whether the
    >> preferred method API is Carbon, BSD, POSIX, or Mach.
    >
    > The Carbon-way would be to use an event timer.  Look in
    > CarbonEvents.h for InstallEventLoopTimer().

    Actually, the ancient mac function Delay() in OSUtils.h would be the
    easiest if you want to resume control in the same block of code.

    alright, that's enough Carbon-talk out of me,
    -Ammon
    --
    Skidperfect Software            <http://www.skidperfect.com/>
  • On Friday, November 16, 2001, at 03:33  PM, Ammon Skidmore wrote:

    >> Is there a preferred method of putting a process to sleep for a second
    >> or two? Basically I would like my process to block  for a specific
    >> period of time, even if it is the front process. The process is a
    >> Carbon app, but I don't really care whether the preferred method API
    >> is Carbon, BSD, POSIX, or Mach.
    >
    > The Carbon-way would be to use an event timer.  Look in CarbonEvents.h
    > for InstallEventLoopTimer().
    >
    > -Ammon
    > -- Skidperfect Software            <http://www.skidperfect.com/>
    >
    >

    I don't think so. My code would continue to execute following my call to
    InstallEventLoopTimer(), which I have more than one of now, and then
    would also be called when the timer fired. I've got a WNE based app, not
    a Carbon Event app and I need blocking at a specific point.

    I am looking to stop execution of my process at a specific line and then
    wake up and continue after said time. I am, since my post, using sleep()
    to perform this task.

    'sleep' is prototyped in "/usr/include/unistd.h". My search paths were
    messed up and I was always finding "sys/unistd.h" which doesn't include
    a declaration for 'sleep'.  When I "man sleep" in the Terminal I get
    documentation on a shell script command 'sleep'. So... I had missed
    finding  'sleep' even though I thought it existed. I found it.

    Thanks for trying to help though. Have a good weekend.

    Rusty
  • On Friday, November 16, 2001, at 04:11  PM, Ammon Skidmore wrote:

    > Rusty,
    >
    >> I am looking to stop execution of my process at a specific line and
    >> then wake up and continue after said time. I am, since my post, using
    >> sleep() to perform this task.
    >
    > Glad you got it to work.  I jumped the gun with my initial
    > recommendation and answered closer to what you wanted shortly
    > afterwards.  Delay() will do the same thing as sleep().
    >
    > -Ammon
    > -- Skidperfect Software            <http://www.skidperfect.com/>
    >
    >

    Only thing is, I don't know the implementation of Delay() on X, it might
    just sit in a loop and count. I don't want to tie up the processor.
    Documentation states that sleep() really puts the task to sleep and lets
    other tasks run, which is what I want to occur.

    Of course it's possible Delay() calls sleep or something like it, though
    they have different granularity of the delay/sleep time.

    Rusty
previous month november 2001 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today