Q2 1-50 Flashcards

2
Q
  1. What are the three main states that any living process may have?
A

Ready to run: Means it could use the CPU immediately (if it is allowed to do so. The scheduler decides which of the ready processes to run next)
Running: For a short slice of time only
Blocked or sleeping: 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
3
Q
  1. What is the Unix process?
A

A process (a program that is executing)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. In Unix, what is the difference between a process ready state and blocked state?
A
Ready = Waiting on the scheduler to decide which process runs next.
Blocked = waiting for event to finish.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. Under which condition does a Unix process enter a blocked state?
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
6
Q
  1. What is the Unix PID?
A

Process ID = Keep track of all processes in the system.Similar to the idea of inodes in case of files, or S.I.N. in our daily life

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. In a Unix operating system, scheduling services are performed by a program called scheduler. What are the main tasks that a schedule perform?
A

Maintains a list of all the processes waiting to execute- Chooses one process at a time, and gives it a chance to runfor a short time called time slice (typically 10 milliseconds)
Saves data related to the interrupted processes so that they canbe resumed later

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. List five of the Unix system calls that coordinate processes. Describe the main function of each of them.
A

fork: creates a copy (child) of the current process (parent)
exec: changes the program that a process is running
wait: forces a process to pause until another process finishing its execution
exit: terminates a process
chomd: change permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. What are the main differences between internal and external Unix commands?
A

Internal commands: Interpreted directly by the shell (no need to create a new process)
External commands: Required the shell to run a separate program (need to create a newprocess)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. Explain what will happen when executing a Unix external command.
A

The shell will use fork system call to createa duplicate of the currently running program. The duplicate (child process) and the original (parent process) proceed from the point of the fork with exactly the same data. The only difference is the return value from the fork call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. In Unix, what is the relation between child and parent processes?
A

The duplicate (child process) and the original (parent process) proceed from the point of the fork with exactly the same data. The only difference is the return value from the fork call.fork returns the child PID to the parent process and 0 to the child process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. What is the Unix PPID?
A

Parent Process ID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. Explain in details what will happen when a process executes the fork system call.
A

Fork is an operation whereby a process creates a copy of itself. It is usually a system call, implemented in the kernel.1. Process is duplicated.2. Child inherits the properties (descriptors) from the Parent.3. The parent and the child share data content (like a pointer).4. If a parent process unexpectedly died,The child will keep executing,The child process is considered to be an orphan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. Explain in details what will happen when a process executes the exec system call.
A

exec: changes the program that a process is running *

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. What is the Unix Zombie state?
A

A zombie process is a process that completed execution but still in process table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. When does a Unix process enter a Zombie state?
A

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process’s entry in the process table remains. The parent can read the child’s exit status by executing the wait system call, at which stage the zombie is removedAfter the zombie is removed, its process ID and entry in the process table can then be reused. However, if a parent fails to call wait, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  1. What is the Unix job?
A

A job refers to all the processes that are necessary to execute anentire command line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
  1. In Unix systems, what is the only living ancestor of all other processes in the system? Explain why.
A

In Unix, toward the end of the boot procedure, the kernelcreates a special process by hand without forking This process is given a PID of 0 (process#0) Process#0 initializes many data structures needed by the kernel At the end, it forks process#1 andthen somehow disappeared (terminated itself)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
  1. In Unix, what is an orphan process?
A

Orphan processes is kind of the opposite situation of zombie processes, since it refers to the case where a parent process terminates before its child processes, in which case these children are said to become “orphaned”.The child will keep executing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
  1. In Unix, when does a process become an orphan?
A

If a parent process unexpectedly died (before the child)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
  1. In Unix, who does adopt orphan processes?
A

Process#1 automatically adopts all orphan processes, hence it receives the control from the child process when finishing execution Informs the kernel to de-allocates the child used resources and kill it

22
Q
  1. In Unix, why orphan processes need to be adopted?
A

In UNIX all processes must be in a single tree, so orphans must be adopted

23
Q
  1. In Unix systems, what will happen if a parent process unexpectedly died before its child finishing its process?
A

Child processes are not notified immediately when their parent finishes. Instead, the system simply redefines the “parent-pid” field in the child process’s data to be the process that is the “ancestor” of every other process in the system, whose pid generally has the value 1 (one), and whose name is traditionally “init”.

24
Q
  1. In Unix systems, what are the main differences between a foreground and a background executions of a program?
A

In the foreground The shell waits for the command to finish before giving another prompt toallow you to continueWhen running a command in the background  you do not have to wait for the command to finish before starting another command Useful when running a command that needs a long time The window will be free so you can use it for other work

25
Q
  1. List five of the Unix signals that are used with the kill command. Describe the main function of each of them.
A

Name Des Used for0 SIGNULL Null Check access to pid1 SIGHUP Hangup Terminate; can be trapped 2 SIGINT Interrupt Terminate; can be trapped3 SIGQUIT Quit Terminate with core dump; can be9 SIGKILL Kill Forced termination; cannot be trapped15 SIGTERM Terminate Terminate; can be traped24 SIGSTOP Stop Pause the process; cannot be trapped25 SIGTSTP Terminal stop Pause the process; can be26 SIGCONT Continue Run a stopped process

26
Q
  1. How similar the Unix stop and kill commands?
A

Kill: Immediate termination (Can not betrapped or ignored by a process)Stop (suspend): sent when you press ^Z

27
Q
  1. How similar the Unix ^z and stop command?
A

Stop (suspend): sent when you press ^Z = same cmd

28
Q
  1. How similar the Unix ^z and kill command?
A

Kill: Immediate termination (Can not betrapped or ignored by a process)Stop (suspend): sent when you press ^Z

29
Q
  1. How similar the Unix ^c and kill command?
A

Interrupt: sent when you press ^CKill: Immediate termination (Can not betrapped or ignored by a process)

30
Q
  1. How do you run a Unix job in the background?
A

-bg JobName -bgUse Jobs to find active jobs.

31
Q
  1. How do you run a Unix job in the foreground?
A

-fgJobName -fgDefault runs the program in the foreground.

32
Q
  1. How do you move a Unix job from the foreground to the background?
A

fg

33
Q
  1. How do you move a Unix job from the background to the foreground?
A

bg

34
Q
  1. In a C-shell, what will happen if a background taska. sends output to the standard output, or standard error, and you have not redirect them?b. requests input from the standard input, and you have not redirected the standard input?
A

a. If a background task sends output to the standard output, or standarderror, and you do not redirect it, output appears on the screen, even if you are running another jobb. Bourne-style shells (i.g., sh, bash) Supply a null string

35
Q
  1. In a Bourne-shell, what will happen if a background taska. sends output to the standard output, or standard error, and have not redirect them?b. requests input from the standard input, and you have not redirected the standard input?
A

a. If a background task sends output to the standard output, or standarderror, and you do not redirect it, output appears on the screen, even if you are running another jobb. C-style shells (e.g., csh, tcsh) Suspend the job and wait for you to give it input

36
Q
  1. Can you start typing the next command before the previous command completed its execution? If yes, how?
A

x

37
Q
  1. How do you display information about the current Unix processes?
A

ps -ef *

38
Q
  1. How do you display information about your current Unix jobs?
A

jobs

39
Q
  1. What is the difference between killing and stopping a Unix process?
A

Kill ends the process. Stop suspends the process.

40
Q
  1. How do you kill a Unix process?
A

kill pid#

41
Q
  1. You started a program named ABC but you realized that it is not behaving and it will take a long time to finish execution. What steps would you take to kill it? If ABC does not respond, what do you do?
A

^c. This will kill the process.

42
Q
  1. How do you stop a Unix process?
A

^z. This will suspend the process.

43
Q
  1. How do you resume a stopped Unix process?
A

It depends on if it is in the fg or bg.fg job#bg job#

44
Q
  1. In Unix while a program is running, what does happen when you press ^c?
A

Kills the program

45
Q
  1. In Unix a program is running, what does happen when you press ^z?
A

Suspends the program

46
Q
  1. In Unix, what is the daemon process?
A

Some of these processes are called daemon: programs running in the background completely disconnected from any terminal

47
Q
  1. Does Unix daemons work in the foreground or in the background?
A

Background

48
Q
  1. In Unix, who is the parent of all daemon processes?
A

the init process (process#1),

49
Q
  1. List eight Unix daemon processes. Describe the main function of each of them.
A

 init: The Unix program which spawns all other processes. crond: Time-based job scheduler, runs jobs in the background. dhcpd: Dynamically configure TCP/IP information for clients. fingerd: Provides a network interface for the finger protocol, asused by the finger command. ftpd: Services FTP requests from a remote system. httpd: Web server daemon. inetd: Listens for network connection requests. lpd: The line printer daemon that manages printer spooling. nfsd: Processes NFS operation requests from client systems.

50
Q
  1. When you give a shell more than one command or when you write a shell script, you must separate them. List 5 command separators in Unix. List the characteristics of each one of them.
A

Newline character: Initiates execution of the command proceeding it’ ; ‘ character: Does not initiate execution of the command proceeding it’ & ‘ character: Does not initiate execution of the command proceeding it. Executes the task in the background’ | ‘ character: Does not initiate execution of the command proceeding it. Pipes the output of the command to the left to the input of the commandto the right’ ( ) ‘ characters, i.e., parentheses: Does not initiate execution of the command proceeding it. Groups commands (the shell treats each group as one job)