CSIS 248 Final Prep

Ace your homework & exams now with Quizwiz!

What is a process control block

(PCB) contains information about the process, i.e. registers, quantum, priority, etc. The process table is an array of PCB's, that means logically contains a PCB for all of the current processes in the system.

What does the Ready process state do?

- After creation of a process, the process enters the ready state i.e. the process is loaded into the main memory. The process here is ready to run and is waiting to get the CPU time for its execution.

What does the New (Create) process state do?

- In this step, process is about to be created but not yet created, it is the program which is present in secondary memory that will be picked up by OS to create the process.

What does the Terminated or completed process state do?

- Process is killed as well as PCB is deleted.

What does the Suspend ready process state do?

- Processes that were initially in ready state but were swapped out of main memory and placed onto external storage by scheduler are said to be in suspend ready state. The process will transition back to ready state whenever the process is again brought onto the main memory.

What does the Suspend wait or suspend blocked process state do?

- Similar to suspend ready but uses the process which was performing I/O operation and lack of main memory caused them to move to secondary memory. When work is finished it may go to suspend ready.

What does the Run process state do?

- The process is chosen by CPU for execution and the instructions within the process are executed by any one of the available CPU cores.

What does the Blocked or wait process state do?

- Whenever the process requests access to I/O or needs an input from user, etc. it enters the blocked or wait state. The process continues to wait in the main memory and does not require CPU. Once the I/O operation is completed the process goes to ready state.

What component of a CPU performs integer arithmetic?

ALU

For the statement "static int x", which segment of a program's virtual address space is used to store x?

BSS

In a virtual address space, which segment contains statically-allocated variables that are not explicitly initialized to any value?

BSS

What are the Two main jobs of the OS in managing processes?

Context Switching & Scheduling

3 of the CPU's Main Components

Control Unit, Arithmetic Logic Unit (ALU), Memory Management Unit

For the statement "static int x = 10", which segment of a program's virtual address space is used to store x?

Data

Which segment of an object file or the corresponding virtual address space of a program contains initialized static variables?

Data

In the PCB what does the Process number state store?

Every process is assigned with a unique id known as process ID or PID which stores the process identifier.

For the statement "int* x = malloc(4)", which segment of a program's virtual address space is used to store the 4 allocated bytes?

Heap

Which segment of a program's virtual address space is managed by malloc, calloc, realloc, and free?

Heap

What is a zombie process?

If the parent decides not to wait for the child's termination and it executes its subsequent task, then at the termination of the child, the exit status is not read.

What is a orphan process?

If the parent ends before the child process, the child becomes and orphan.

How does the wait() function work?

If the parent process calls wait() system call, then the execution of parent is suspended until the child is terminated.

In the PCB what does the Pointer store?

It is a stack pointer which is required to be saved when the process is switched from one state to another to retain the current position of the process.

In the PCB what does the Program counter store?

It stores the counter which contains the address of the next instruction that is to be executed for the process.

In the PCB what does the Process state store?

It stores the respective state of the process.

Which segment of virtual memory that has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource and is often used to load shared libraries of code?

Mapped Memory

List the 7 process states

New(create), Ready, Run, Blocked or wait, Terminated or completed , Suspend ready, Suspend wait or suspend blocked

Which part of the machine translates a virtual address to a physical one?

OS kernel

What 8 items make up the Process Control Block (PCB)

Pointer, Process state, Process number Program counter, Register, Memory limits, Open files list, Miscellaneous accounting and status data

When a child process terminates, which signal is sent to the parent process by the kernel?

SIGCHLD

For a function with prototype "int fun(int a, int b)", which segment of a program's virtual address space is used to store the function's parameter values when the function is called?

Stack

For the statement "int* x = malloc(sizeof(int))", which segment of a program's virtual address space is used to store the pointer variable x?

Stack

Which segment of a program's virtual address space contains a LIFO structure?

Stack

Which segment of a program's virtual address space typically manages function calls by storing the return address of the instruction to execute when a function ends?

Stack

Which segment of a the user space of a program's virtual address space contains the largest address values?

Stack

Which segment of a program's virtual address space contains executable instructions?

Text

Which segment of a program's virtual address space contains the smallest address values?

Text

Consider the following segments of the virtual address space. BSS Stack Data Text Heap Kernel Space Identify the sequence that corresponds to the ordering of the address segments from lowest addresses to highest with the leftmost segment begin the segment containing the lowest addresse

Text, Data, BSS, Heap, Stack, Kernel Space

In the PCB what does the Register store?

These are the CPU registers which includes: accumulator, base, registers and general purpose registers.

In the PCB what does the Memory limits store?

This field contains the information about memory management system used by operating system. This may include the page tables, segment tables etc.

In the PCB what does the Miscellaneous accounting and status data store?

This field includes information about the amount of CPU used, time constraints, jobs or process number, etc.

In the PCB what does the Open files list store?

This information includes the list of files opened for a process.

What is a pid?

a 5 digit ID number unix/linux keeps account of the processes, this number is call process id -At any point of time, no two processes with the same pid exist in the system because it is the pid that Unix uses to track each process.

In Linux/Unix, new process are started when _______.

a running process forks a child process

What does the fork() do?

a system call that creates a new process by duplicating the calling process.

A terminated process with an entry in the process table is called ___________ process.

a zombie

When a parent process terminates before its child process, the child process is called ___________ process.

an orphan

Which command can be used to run a process in the background.

bg

What is machine code?

computer program written in machine language instructions that can be executed directly by a computer's central processing unit (CPU)

Describe Scheduling

consists of choosing a new process among the processes that are eligible for execution.

Describe Context Switching

consists of stopping one process and starting a new one.

What is a process table?

data structure maintained by the operating system to facilitate context switching and scheduling

how to declare a function pointer in main?

data type (*name)(argument) = function name

How do you execute a new process?

exec()

What does exec() do?

family of functions replaces the current process image with a new process image. It loads the program into the current process space and runs it from the entry point.

How do you start a process?

fork()

typedef is used to i create a name that is an alias for a previously defined data type. ii initialize struct members. iii create new data types iv cast one struct to another type.

i create a name that is an alias for a previously defined data type.

In gdb, which of the following can be used to delete a breakpoint on line 7. i delete 7 ii unbreak 7 iii d $7 iv remove 7

i delete 7

What function should be used to free the memory allocated by malloc() ? i free ii calloc iii dealloc iv memalloc

i free

Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program? #include #include int main() { struct ex { int i; float j; char *s }; struct ex *p; p = (struct ex *)malloc(sizeof(struct ex)); p->s = (char*)malloc(20); return 0; } i free(p->s); free(p); ii free(p->s); iii free(p); iv free(p); free(p->s);

i free(p->s); free(p);

Specify the 2 library functions to dynamically allocate memory? i malloc() and calloc() ii memalloc() and faralloc() iii alloc() and memalloc() iv malloc() and memalloc()

i malloc() and calloc()

In gdb, which of the following can be used to take a single step to the next machine instruction, while stepping over function calls. i ni ii s iii n iv si

i ni

In gdb, which of the following can be used to take a single step to the next machine instruction, stepping into function calls. i si ii n iii s iv ni

i si

Function __________ searches for the first occurrence of a character in a string. i strchr ii firstchr iii getfirst iv firstchar

i strchr

Given that k is an integer array starting at location 2000, kPtr is a pointer to k, and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to? i 2006 ii 2012 iii 2003 iv 2024

ii 2012

In gdb, which of the following can be used to take a single step to the next statment of code, while stepping over functions. i si ii n iii ni iv s

ii n

In gdb, which of the following can be used to start the program being debugged. i go ii r iii s iv g

ii r

In gdb, which of the following can be used to take a single step to the next statment of code, including stepping into functions. i ni ii s iii si iv n

ii s

Function __________ searches for the first occurrence in its first string argument of any character in its second string argument. i strfirst ii strpbrk iii strstr iv firstany

ii strpbrk

Three of the following expressions have the same value. Which of the following's value is different from the others? i *&Ptr ii &*Ptr iii *Ptr iv Ptr

iii *Ptr

An orphan process will be adopted by which process ______.

init

What is an object file?

is a file containing object code

__________ are collections of related variables under one name. i Files ii Members iii Enumerations iv Structures

iv Structures

In gdb, which of the following can be used to set a breakpoint on line 7. i b $7 ii p 7 iii b iv b 7

iv b 7

In gdb, which of the following can be used to list lines of source code. i k ii m iii j iv l

iv l

In gdb, which of the following can be used to print the value of a variable. i r ii s iii q iv p

iv p

Which of the following statement is correct prototype of the malloc() function in c ? i unsigned int* malloc(unsigned int); ii char* malloc(char); iii int* malloc(int); iv void* malloc(size_t);

iv void* malloc(size_t);

Which command can be used to send a signal to a process.

kill

Which command can be used to view a list of signals that can be sent to a process.

kill -l

What does Address translation (a.k.a. address binding) mean?

mapping virtual addresses to physical addresses.

What does a linker program do?

one or more object files generated by a compiler or an assembler and combines them into a single executable file

Which command can be used to view a snapshot of the current processes.

ps

The stack is used to keep track of function calls by pushing data called a _______ onto the stack.

stack frame

ebp/rbp

stores address of a stack frame

eip/rip

stores address of executing instruction

esp/rsp

stores address of the top of the stack

esi/edi/rsi/rdi

stores values for function inputs

Virtual (or logical) addresses are provided by__________?

the OS kernel

When a function is called which of the following typically occurs?

the calling function base pointer is pushed onto the stack

Physical addresses are provided by___________?

the hardware

Which of the following is not contained in a functions stack frame?

the instruction pointer

Which of the following is not contained in a process control block?

the processes stack

eax/rax

used to store return value of function

Keyword __________ introduces the structure definition. i structure ii strdef iii str iv struct

vi struct

How to wait on a process?

wait()


Related study sets

5.8 Financial Responsibility, Insurance, and Collisions Quiz

View Set

Ch 71 Cyclooxygenase Inhibitors: Nonsteroidal Anti-Inflammatory Drugs and Acetaminophen

View Set

Ch. 14: Gender and Leadership Exam Review 3 (MGMT 4470)

View Set

Prepare: Worksheet 13.1: What is Consideration?

View Set