2

My understanding is A waiting process is a situation in which process is waiting for the completion of some event before resuming activity. A program or process in a wait state is inactive for the duration of the wait state.

Basically in the above the waiting on some event to occur.

what about sleeping?

user2927486
  • 111
  • 2
  • 8

6 Answers6

1

Sleep causes the process to give up the remaining of its time slice and stay in non-runnable state for the given duration Vs Wait: pauses execution until an event completes.

Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46
0

A process, as you rightly said- waits on an event. A sleep is a time driven wait.

erbdex
  • 1,899
  • 3
  • 22
  • 40
0

Please check this on Wikipedia: http://en.wikipedia.org/wiki/Process_state .

Ready or waiting, it's more CPU resource linked:

A "ready" or "waiting" process has been loaded into main memory and is awaiting execution on a CPU 

Sleeping, see also In *nix, what causes "sleeping" in top command?, it's more functional designing:

It's waiting for data, interaction with other processes, like an Apache server that waits for a user query, it's a more normal process state...

Community
  • 1
  • 1
jacouh
  • 8,473
  • 5
  • 32
  • 43
  • 1
    Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Hasturkun Oct 28 '13 at 09:49
0

"wait" : if you executed command shell will wait(hold) and does not execute any more command until the command is finished successfully and switches to next.

"sleep" : if the command you run is sleep 10, then it spend 10 seconds not outputting anything. So the shell spends 10 seconds in an internal wait on the sleep process.

suhas
  • 733
  • 5
  • 13
0

sleep: This command is issued to suspend execution of the system for the specified time limit mentioned in it as parameter.

For instance

sleep 50

The above suspend the execution of the shell in UNIX operating system for 50 seconds specified.

wait: wait causes waiting of the process specified in parameter or the job specified in parameter to wait. If nothing is specified all jobs in pipeline are put to waiting state that is all current child process which are currently active are put to wait status. Wait also return the return status. If a child has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed. The return status is generally the exit status of last job in the pipeline process which was put to waiting state. In case of scenario in which no job or process is specified the return status would be zero.

The general syntax of wait command in UNIX operating system is

wait n

where n is optional which denote the process or job

Srini V
  • 11,045
  • 14
  • 66
  • 89
0

In Unix

  • Waiting: is the fact that a process is waiting for some external event like the reception of data from the network, reading bytes from disk etc...

  • Sleeping: is the fact that a process puts itslef in an unrannable state for a period of time, how it is done in unix is via alarm syscall

Both for Waiting processes and Sleeping processes are in fact waiting for some external event or a signal to go into the ready state so that it can be picked up by the scheduler and fed to the CPU to continue its exceution (running state)

TLDR

Both of them are a WAITING state.

achabahe
  • 2,445
  • 1
  • 12
  • 21