1 - Shell (Part 1) Flashcards

1
Q

What does information on a process include:

A

1) Process Stack: includes temporary data (function parameters, return addresses and local variables)
2) Data Selection: Includes global variables
3) Heap: Memory that is dynamically allocated during process run-time

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

What are the 4 states a process can have:

A

1) New
2) Running
3) Waiting
4) Terminated

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

How is a process represented in the operating system?

A

A process control block.

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

What information does a process control block include?

A

Information related to program execution including:

  • PID
  • state
  • program counter
  • CPU registers
  • CPU-scheduling information
  • Memory-management information
  • I/O Status Information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Examples of operating system services from user-perspective:

A

1) User interface (CLI or GUI)
2) Program execution
3) I/O Operations
4) File-system manipulation

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

What is the command interpreter?

A

A program that accepts commands from the user and interprets the commands (type of user interface).

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

What is a system call?

A

Allows a command to request a service from the operation system.

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

When a command is executed, what carries out the execution?

A

A separate process from the shell process - a child process will execute the command.

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

What does the fork() command do?

A

Creates a child process that is a duplicate of the parent.

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

What are the properties of a child process created by fork()?

A
  • Child inherits state from parent process (same program instructions, variables have the same value)
  • Parent and child have separate copies of that state
  • Child has the same open file descriptors from the parent (might be from 2208)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Switching between the parent and child depends on many factors such as:

A
  • machine load

- system process scheduling

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

How many processes are created by 4 consecutive fork commands?

A

Draw out process tree.

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

Does this code produce a tree or a chain?
pid_t childpid = 0;
for (i=1;i

A

Tree.

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

Does this code produce a tree or a chain?
pid_t childpid = 0;
for (i=1;i 0)
break;

A

Chain of child processes.

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

How many times does a fork() command return and what does it return?

A

A fork system call returns twice: 1) returns a zero to the child. 2) returns the child process ID (PID) to the parent)

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

What gets copied when you use a fork() command?

A

The file descriptor table. Thus, the parent and child point to eh same entry in the system file table.

17
Q

What does the term Exec refer to?

A

A family of functions where each of the functions replace a process’s program (the one calling one of the exec functions) with a new loaded program.

18
Q

A call to a function from exec loads what type of file into memory?

A

A binary file.

19
Q

What happens to the original the original memory image of the programming calling the exec function?

A

It destroys the memory image image of the program calling it.

20
Q

Referring to the exec function family: Functions with “p” in their name do what? ex. execvp, execlp

A

Search for the program in the path indicated by the PATH environment variable; functions without p must be given full path

21
Q

Referring to the exec function family: Functions with “v” in their name do what? ex. exec, execvp, execve

A

They differ from functions with l (execl, execlp, execle) in the way arguments are passed.

22
Q

Referring to the exec function family: Functions with “e” in their name do what?

A

Functions with “e” accept array of environment variables.

23
Q

True or false: The child return to the old program if exec succeeds.

A

False! Child will not retune to the old program unless exec fails. This is an important point to remember.

24
Q

True or false: File descriptors are not preserved when a child calls an exec onto itself.

A

False, file descriptors ARE preserved.