Topic 6 - Process & Job Control 1 Flashcards Preview

CS 2211 - Unix > Topic 6 - Process & Job Control 1 > Flashcards

Flashcards in Topic 6 - Process & Job Control 1 Deck (58):
1

All processes are handled and managed by:

the kernel through a scheduling services called the scheduler

2

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

Only one process

3

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

Either one of three:
1) Running
2) Ready to run
3) Blocked or sleeping

4

What does a Running Process mean?

Is executing for a short slice of time only

5

What does a Ready Process mean?

It could use the CPU immediately if it is allowed to do so.
The scheduler decides which of the ready processes to run next

6

What does a Blocked or Sleeping process mean?

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

7

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?

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

8

How does the system keep track of all the processes?

A process table

9

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

A process ID is created, or simply, PID.

10

Within Unix, every object is represented by?

Either a file or a process.

11

A process is a program that is started by:

Either a user or the system

11

What maintains the process table?

Maintained by the kernel

12

What are the characteristics of a process table?

1) Indexed by the PID
2) Contains one entry for each process to store its attributes

13

List the 3 things a scheduler does:

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

14

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

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

15

System calls provides an __________ between________ and _______.

an essential interface between a process and the operating system

16

What is the rule of process creation?

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

17

There are 4 types of System Calls:

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

18

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

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

19

Some of the system calls that co-ordinate processes include the following. Describe them.
Fork:
Exec:
Wait:
Exit:
Kill:

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

20

What are the two types of commands?

1) Internal Commands
2) External Commands

21

Define Internal Commands

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

22

Define External commands

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

23

How do you run an external command?

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

24

The fork() command returns what?

- 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

How do you identify a child process?

Fork() returns 0

26

The child process uses an exec system call to:

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

27

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

- 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

Go through the steps when a child process finishes execution.

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

What does Process#0 do?

- 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

How is Process#0 created?

kernel creates it by hand without forking

31

What is another name for Process#1?

the init process

32

What does Process#1 / the init process do?

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

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

The init process (process#1)

34

Describe process#1 besides what it does.

- 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

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?

- 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

Define: job

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

37

How do you run a command in the background?

Use the "&" symbol at the end of the command line.

38

How do you send a signal to a process?

Using the Kill command

39

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

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

Describe the Kill command:

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

Give examples of Standard signals.

SIGHUP
SIGINT
SIGKILL
SIGTERM
SIGSTOP
SIGCONT

42

Define: SIGHUP

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

43

Define: SIGINT

Interrupt: sent when you press ^C

44

Define: SIGKILL

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

45

Define: SIGTERM

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

46

Define: SIGSTOP

Stop (suspend): sent when you press ^Z

47

Define: SIGCONT

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

48

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

SIGTERM is sent - *Requests* that the process to exit

49

Which processes can be intercepted or even ignored?

All signals except of SIGKILL and SIGSTOP.

50

SIGKILL and SIGSTOP are only seen by the ______

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

51

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

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

Can Ctrl-C interrupt key abort a background process?

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

53

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

%4 (where "4" is a hypothetic job ID)

54

What does the command "bg" mean?

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

55

What does the fg command do?

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

56

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

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

57

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

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