L7: Processes Flashcards

1
Q

Process Creation:

Key Process Routines

A
  • fork
  • exec
  • wait
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Process Communication:

Key Routines

A

These facilitate read/write between processes:

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

Process Controlling:

Key Routines

A

Cause and Handle exeptions and interrupts:

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

3 Major Categories of

Process Operations

A
  • Process Creation
  • Process Communication
  • Process Control
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

fork() function:

Basic Idea

A

Clone an existing process,

then have it run an alternate set of code from

the parent.

The child “forks” from the parent.

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

Which library contains the “fork()” function?

A

unistd.h

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

Forking:

Sequence of steps

A
  1. execute “fork()”
  2. The complete parent state is cloned to create the child process.
    • Child is created.
  3. The “fork()” call returns
    • pid of child, in parent process
    • 0, in child process
  4. Return value is used to determine next step:
    • parent executes parent code
    • child executes child code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Code:

Have Parent Process

wait for

Child Process to finish

A

int status;

if( fork() ) {

//parent process stuff

wait(&status); //wait for child to update status

exit(0); //parent exits

}

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

exec() function:

Basic Use

A
  1. Use fork() to get a child process
  2. In the child process, use “execlp()” or “execvp()”
    • This will “overlay” the image of the new program onto the child image
    • The existing context(such as the file descriptors) is preserved
  3. The Child process now runs as the second program, and exits with a status code
  4. The parent process waits for the child to complete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

exec:

Two Formats

A
  • execlp( filename, argv0, argv1, …, (char *)0);
    • The last parameter must be null
  • execvp(filename, argv);
  • filename can be a program or a script
  • image of the current process is replaced, can only return if that fails
  • Most Context is preserved
  • stdio buffers are NOT FLUSHED
    • must close or flush them manually using fflush or fclose before exec
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a

Process?

A
  • An instance of an executing program
  • A fundamental concept in Computer Science and a powerful coding technique
  • Performs independent computations
  • Processes interact via messages
  • Identified using a process id (pid)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Possible Process States

A
  • running
    • actually executing on machine
  • sleeping
    • ready to run, waiting for its turn
  • idle
    • sleeping for more than 20 seconds
  • waiting
    • waiting for an event, such as disk I/O
  • zombie
    • processes ended, but the parent has not yet recieved notification from the system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly