Topic 6 - Process & Job Control 1 Flashcards

1
Q

All processes are handled and managed by:

A

the kernel through a scheduling services called the scheduler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In a single-processor computer, how many processes can be running at a time?

A

Only one process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the statuses a process can have at a time?

A

Either one of three:

1) Running
2) Ready to run
3) Blocked or sleeping

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does a Running Process mean?

A

Is executing for a short slice of time only

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does a Ready Process mean?

A

It could use the CPU immediately if it is allowed to do so.

The scheduler decides which of the ready processes to run next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a Blocked or Sleeping process mean?

A

Waiting for an event to occur, e.g., I/O or signal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can you go from:

1) Running to Ready to Run?
2) Running to Blocked / Sleeping?
3) Ready to Run to Running?
4) Ready to Run to Blocked / Sleeping?
5) Blocked / Sleeping to Running?
6) Blocked / Sleeping to Ready to Run?

A

1) Yes
2) Yes
3) Yes
4) No
5) No
6) Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does the system keep track of all the processes?

A

A process table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the first thing that happens when a process is created?

A

A process ID is created, or simply, PID.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Within Unix, every object is represented by?

A

Either a file or a process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A process is a program that is started by:

A

Either a user or the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What maintains the process table?

A

Maintained by the kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the characteristics of a process table?

A

1) Indexed by the PID

2) Contains one entry for each process to store its attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List the 3 things a scheduler does:

A

1) Maintains a list of all the processes waiting to execute
2) Chooses one process at a time, and gives it change to run for short time called time slices (typically 10 milliseconds).
3) Saves data related to the interrupted processes so that they can be resumed later

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when a process needs the kernel to perform a service?

A

It sends a request (a system call) which will create new a process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

System calls provides an __________ between________ and _______.

A

an essential interface between a process and the operating system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the rule of process creation?

A

Every created process is a child process where it was generated from another parent process. (Except the first process during boot up)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

There are 4 types of System Calls:

A

1) File-related calls
2) Information-related calls
3) Communication-related calls
4) Process-related calls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Define:

1) File-related calls
2) Information-related calls
3) Communication-related calls
4) Process-related calls

A

1) Opening- closing reading from or writing file
2) Information related calls - getting date / time
3) interprocess communication
4) Creating, executing, stopping a process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
Some of the system calls that co-ordinate processes include the following. Describe them.
Fork:
Exec:
Wait:
Exit:
Kill:
A

Fork - creates a copy (child) of current process (parent)
Exec - changes the program that a process is running
Wait - forces a process to pause
Exit - terminate a process
Kill - send a signal to another process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are the two types of commands?

A

1) Internal Commands

2) External Commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Define Internal Commands

A

Intercepted directly by the shell (no need to create a new process)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Define External commands

A

Required the shell to run a separate program (need to create a new process)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do you run an external command?

A

Use the fork system call to create a duplicate of the currently running program. Key point here is currently running program is duplicated.

24
Q

The fork() command returns what?

A
  • Returns the child PID (a positive number) to the parent process
  • 0 to the child process
  • A negative value, the creation of a child process was unsuccessful
25
Q

How do you identify a child process?

A

Fork() returns 0

26
Q

The child process uses an exec system call to:

A

to change itself from a process running the shell into a process running the external command

27
Q

At the same time a child process is made & running, what is the parent process doing?

A
  • identifies itself by a positive value from the return value of the fork
  • Uses the Wait system call to pause itself until the child is finished the execution
28
Q

Go through the steps when a child process finishes execution.

A

1) Uses Exit system call
a) send a signal to the parent process indicating the it is done
b) go to a zombie state waiting for the terminating status to be accepted

2) Parent process receives a wake up signal from child
a) Informs kernel to do 2 things;
1) De-allocate the child’s used resources
2) Removes the child PID from the process table, killing the child

29
Q

What does Process#0 do?

A
  • Initializes many data structures needed by the kernel.

- At the end of the boot procedure, process#0 forks process#1 and then disappears by terminating itself

30
Q

How is Process#0 created?

A

kernel creates it by hand without forking

31
Q

What is another name for Process#1?

A

the init process

32
Q

What does Process#1 / the init process do?

A

Carries out the rest of the steps that are necessary to set up the kernel and finishes the boot process (in doing so, many processes are created by init).

33
Q

What is the only living ancestor of all other processes in the system?

A

The init process (process#1)

34
Q

Describe process#1 besides what it does.

A
  • Is the first process in the process table
  • stays there until the system is shut down
  • Is the only living ancestor of all other processes in the system
35
Q

What happens when a parent process unexpectedly dies? Does the child die prematurely? Do we have a rogue child process that lives on forever without a parent to kill it and keeps resources hostage?

A
  • Called an orphan
  • The child will keep executing until its done.
  • Process#1 automatically adopts all orphan process and receives the control from the child process when its finished executing it
  • Informs the kernel to de=allocate the child used resources and kill it
36
Q

Define: job

A

A job refers to all the processes that are necessary to execute an entire command line.

37
Q

How do you run a command in the background?

A

Use the “&” symbol at the end of the command line.

38
Q

How do you send a signal to a process?

A

Using the Kill command

39
Q

What is displayed / seen by the user when a background command is given to the shell?

A

1) The shell will display the job number (job ID) that identifies the command
2) display the Process ID (PID) number for each running process in the background
3) Give you another prompt

40
Q

Describe the Kill command:

A

A command used to send a signal to a process.

It is a wrapper around the kill() system call, which sends signals to processes on the system.

41
Q

Give examples of Standard signals.

A
SIGHUP
SIGINT
SIGKILL
SIGTERM
SIGSTOP
SIGCONT
42
Q

Define: SIGHUP

A

hangup - sent to process when you logout or if your terminal is disconnected

43
Q

Define: SIGINT

A

Interrupt: sent when you press ^C

44
Q

Define: SIGKILL

A

Kill: immediate termination (Can not be trapped or ignored by a process)

45
Q

Define: SIGTERM

A

Terminate: request to terminate; (Can be trapped or ignored by a process)

46
Q

Define: SIGSTOP

A

Stop (suspend): sent when you press ^Z

47
Q

Define: SIGCONT

A

Continue: resume suspended process; usually sent by the fg or bg commands

48
Q

If no single is specified in the kill command, by default, what happens?

A

SIGTERM is sent - Requests that the process to exit

49
Q

Which processes can be intercepted or even ignored?

A

All signals except of SIGKILL and SIGSTOP.

50
Q

SIGKILL and SIGSTOP are only seen by the ______

A

The host system’s kernel, providing reliable ways of controlling the execution of processes.

51
Q

What are the requirements for a process to successfully send a signal to another?

A

Essentially, for a process to successfully send a signal to another, the owner of the signalling process must be the owner of the receiving process or be the super-user

52
Q

Can Ctrl-C interrupt key abort a background process?

A

No, only a kill command can. Ctrl-C can only abort a foreground process.

53
Q

How do you specify a job ID in the command line?

A

%4 (where “4” is a hypothetic job ID)

54
Q

What does the command “bg” mean?

A

Lists background jobs. Without job number means, the most recent stopped job.

55
Q

What does the fg command do?

A

Transfer a process from the background to the foreground and make it the current process.

56
Q

If a background task sends output to the standard output, or standard error, and you do not redirect it - what happens?

A

output appears on the screen, even if you are running another job

57
Q

If a background task requests input from the standard input, and you have not redirected the standard input - what happens?

A

Depends on the shell type:

  • bourns-style shells: supplies a null string
  • Suspends the job and waits for you to give it input.