Quiz #4 Flashcards

1
Q

How many program can execute at a time without a O/S?

A

Without an O/S, only one program can be executed at a time

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

How do you change the running program

A

A CPU reset and some way of loading a new program (flashing, loading from tape, etc.) is required to change the running program,.

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

How much control does the running program have?

A

The running program has full control and 100% use of the resources of the computer(since It is the only thing running)

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

How many programs can be ran with a O/S?

A

O/Ses allow more than one program to be loaded at a time and allow us the ability to switch between loaded programs using the concept of a process

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

What is a process? What can you do with them

A

a process is a program in execution. A process can be paused, restarted, stored and executed

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

What are the parts of a process?

A
  • Processor registers including the program counter
  • The program code, also called text section
  • Stack containing temporary data; Function parameters, return addresses, local
    variables
  • Data section containing global variables
  • Heap containing memory dynamically
    allocated during run time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a process’s address space? What are segments?

A
  • A process’s address space is the range of memory addresses accessible by that process.

The address space is comprised of 3
segments and the heap. The text
segment, contains the executable code
(called the program text, but it is NOT
text!). the data segment contains
constant and global data. The stack
segment contains local variables.
Highest Memory Address

Stack
Heap
Data
Text

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

A program is a ____ entity stored on disk ( ____ ___), a process is ___

Programs become ___ when executed

every process must have ____ ____ ____

Several process may have the ___ ___

A

passive, executable file, active

process

exactly one program

same program

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

What is a process

A

A process is an activity of some kind. It
has a program, an address space input, output
and a register state.

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

What is a program?

A

A program is a set of executable instructions
that may be stored on disk, not necessarily
doing anything

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

If a program is running ___, it counts as ___ processes. The fact that ___ processes are running the same program doesn’t matter. They are ___ ____ processes.

A

twice, 2, two, 2 distinct

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

Which is a program and a process? A movie on a dvd, playing the movie

A

program - a movie on a dvd
process - playing the movie

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

Two users are logged into a single-CPU Linux server. User #1 begins a lengthy process to calculate pi to 50 decimal places: 3.14159265358979323846…. User #2 begins a equally lengthy process to sort 1000 names. Both users claim that the CPU is working on her problem. How can this be? There is only 1 CPU.

A

O/Ses allow more than one program to be loaded at a time and allow us the ability to switch between loaded programs using the concept of a process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  • CPU switches from process to process quickly, giving the illusion of ____
  • Each process is allowed to run for tens or hundreds of millisecond stretches (called a ____ ____ or ____ )
  • This rapid switching is called _____
A

parallelism

time slice, quantum

multiprogramming

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

How does the CPU do multiprogramming?

A
  • multiprogramming through rapid
    context switching between processes amounts to the O/S abstracting a single physical CPU into multiple virtual CPUs (one per process).
  • From each process’s point of view, it is running
    on a dedicated CPU.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the core component of the operating system kernel? What is above that layer?

A

process scheduler

the set of processes to be sequentially executed

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

As process executes, it changes state. What are those states and what do they mean?

A
  • new: The process is being created
  • running: Instructions are being executed
  • waiting: The process is waiting (blocked) for some event to occur
  • ready: The process is waiting to be assigned to a processor
  • terminated: The process has finished
    execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the diagram of process state?

A
  1. Process newly created blocks for input, New -> Ready
  2. Process picked to run becomes available, Ready -> Running
    3 - Another process picked to run, Running -> Ready
    4 - Process, Running -> Waiting
    5 - Input, Waiting > Ready
    6 - The process ends, Terminated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the process control block(PCB)

A

an array of structures maintained by the kernel

20
Q

What do PCB entires contain?

A

information about the process’ state, including its program counter, stack pointer, memory allocation, the status of its open files, its accounting and scheduling information, etc

Everything that must be know to transition a process between running, ready and blocked states

21
Q

What is the task control block?

A

Information associated with each process
(also called task control block)

22
Q

What is PCB components and what do they mean?

A
  • Process state – running, waiting, etc
  • Program counter – location of instruction to next execute
  • CPU registers – contents of all process-
    centric registers
  • CPU scheduling information- priorities,
    scheduling queue pointers
  • Memory-management information –
    memory allocated to the process
  • Accounting information – CPU used,
    clock time elapsed since start, time limits
  • I/O status information – I/O devices
    allocated to process, list of open files
23
Q

Which of the following would NOT likely be stored in a PCB entry?
❑ Current Time
❑ Process’s State
❑ # of Running processes
❑ Stack Pointer
❑ Scheduler’s State

A

❑ Current Time

24
Q

List at least 3 elements that every process must have.

[Hint: what must be stored in order to completely halt then fully restore a running process?]

A

Process Identifier, Program Counter (PC), Process State

25
Q

What is the point of multiprogramming?

A

Multiprogramming aims to have a process running at all times to maximize CPU utilization

26
Q

Where does the process scheduler selects a ‘Ready’ process? Where do other ‘ready’ process wait? Where are 3 things a process will either be?

A
  • The process scheduler selects a ‘Ready’ process for execution on the CPU
  • All other ‘Ready’ processes wait in a Ready Queue
  • Processes are either running, in the Ready Queue or waiting on I/O in an I/O Queue.
27
Q

What is a short-term scheduler or Cpu scheduler?What is a Long-term scheduler (or job scheduler)?

A

Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU
* Sometimes the only scheduler in a system
* Short-term scheduler is invoked frequently (milliseconds) ⇒ (must be fast)

Long-term scheduler (or job scheduler)
– selects which processes should be brought into the ready queue
* Long-term scheduler is invoked infrequently (seconds, minutes) ⇒ (may be slow)
* The long-term scheduler controls the degree of multiprogramming

28
Q

What can process either be describer as?

A
  • I/O-bound process – spends more time
    doing I/O than computations, many short
    CPU bursts
  • CPU-bound process – spends more
    time doing computations; few very long
    CPU bursts
29
Q

Describe CPU utilization with 20% I/0 wait, 50% IO wait, and 80% I/o wait

A

20% reaches higher cpu utilization faster
50 has is in-between 20% and 80% I/o wait(bingo closer to 20%), and *0% as a steady sloper

30
Q

What is a I/O-bound process? What is CPU - bound process?

A
  • A process that spends most of its time waiting on I/O is said to be an I/O-bound process.
  • A process that spends most of its time running of the CPU is said to be a CPU-bound process.
31
Q

What is the context or state of a process? Where is it stored? What does it include?

A
  • The context or state of a process is all the information needed to suspend and later restore a running process
  • The context is the information stored in the PCB and includes
  • CPU registers & program counter
  • memory management information
  • process state
32
Q
  • Switching the CPU from a running process to another ready process amounts to
  • performing a _____ ____ on the current
    process.
  • performing a ____ ____ on the process to
    resume.
A

state save

state restore

33
Q

What is context switching?

A
  • Switching from one process to another is known as a context switch.
34
Q

Is context switching costly? What does the time depend on? What is it dependent on?

A
  • Context switching is costly, typically requiring a few milliseconds of time during which no useful work is being done.
  • Context switch time depends on the number of CPU registers that must be saved/restored.
  • Context switch time highly dependent on hardware support. Some CPUs can load/store all registers with a single instruction.
35
Q
  • The creating process is called the ____ _____
  • The created process is called the _____ ____
  • All processes are identified by a ____ _____
A

parent process
child process
Process ID (PID) number

36
Q

In Unix, we use the ____ system call to create a new process
* In Windows, use the ________ Win32
API to create a new process
* What typically one of two things happens after a new process is created
1.
2.

A

fork( )
CreateProcess( )

  1. The parent continues to execute concurrently with its child (or children)
  2. The parent waits until its child (or children) has terminated before continuing
37
Q

How does fork() work? How is it implemented?

A
  • fork() creates an exact clone of the calling process. The parent and child processes have the same memory image (program). The child’s initial address space (program + variables) is a copy of the parent’s.
  • Usually, the child process executes an execv() system call to change its memory image and run a new program
  • Some Unix implementations share the process image (program text) between parent and all its children. The child process may subsequently change its process image with a call to execv()

Unlike the Unix implementation, CreateProcess() combines the steps of forking and process image replacement. Thus, the parent and child’s
address spaces are distinct from the start.

38
Q

What are the key differences between a
program and a process?

A

Program: Passive. It remains inactive until executed. The program instructions are stored on a secondary storage device like a hard drive.
Process: Active. It’s a dynamic entity that comes alive when the program is loaded into memory and starts executing. A process can be in various states like running, waiting, or terminated.

39
Q

What are the typical conditions which terminate a process?

A

Typical conditions which terminate a process:
1. Normal exit (voluntary).
2. Error exit (voluntary).
3. Fatal error (involuntary).
4. Killed by another process (involuntary)

Unix → exit()
Windows → ExitProcess

40
Q

What is waitpid()

A
  • A parent can wait for its child process to exit by using the waitpid() system call
    pid_t waitpid(pid_t pid, int *child_status, int options);
    where,
  • pid is the process ID of the child we are waiting to complete.
  • child_status is an integer returned by the terminated child process.
  • options can be set to 0.
41
Q

Typically, after executing a ____ function , the newly created child process will change its program.
* The ____ function can be used to do this.

A

fork()
execv()

42
Q

Is fork a system call?

A

yes

43
Q

What does the fork function return when it fails?

A

-1

44
Q

All children of the parent process have the same process id?

A

False

45
Q

How do you create a new process

A

unix fork

46
Q

Every time you spawn a child process it inherits the parents stack from the parents

A

true