Operating Systems

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Select all the correct rules for MLFQ.

- If Priority(A) > Priority(B), A runs (B doesn't). If Priority(A) = Priority(B), RR(A, B) When a job enter the system, it is placed at the highest priority (the top most queue). Once a job uses up its time allotment at a given level (regardless of how many time it has given up the CPU), its priority is reduced. After some time period S, move all the jobs in the system to the topmost queue.

In C, fork() is a function that is responsible for creating a new process. Select all statements that are correct about fork() from the list below.

- The new process is an almost exact copy of the calling process. - The parent process receives a return code which is the new process's pid from fork().

Select all that are shared in a multi-threaded program.

-Dynamic objects allocated from heap. -Global variables

Select the correct statements describing state of a single thread.

-Each thread has its own program counter. -Each thread has its own private set of registers for computation.

Which of the followings are the minimum required set of simple assumptions for a Round-Robin scheduler?

-The run time of each job is known -All jobs only use the CPU (no I/O)

Which are needed to translate a virtual address into physical address?

-Virtual page number (VPN) -offset

which of the following flag enables debugging attributes?

-g

Given an array A currently containing 5 numbers, 0, 2, 4, 6, and 8. When printed out, the address of A is at 0x0600. What is the sequence of addresses for all elements in Array A?

0x0600, 0x0608, 0x0610, 0x0618, 0x0620.

Given the follow body of code, select the correct value printed out to the screen. #include <stdio.h> int mul1(int i) { i = i * 2; return i; } int mul2(int *a_pointer) { *a_pointer = (*a_pointer) * 3; *a_pointer = mul1(*a_pointer); return *a_pointer; } int main(int argc, char *argv[]) { int i = 5; int x = mul2(&i); printf("Value of i: %d\n", i); return 0; }

30

Program A contains the following segment. Assume that A compiles and runs with no errors, and all processes spawned by A's fork() calls exit gracefully. How many new processes, besides the initial process of A when it was first started, were spawned?

4

The error shown in the concurrency hands-on activities is due to

Competing threads incorrectly increment the same value

Match the following optimization solutions with their corresponding problems

DMA device - PIO overhead due to CPU moving data to devices. Interrupts - CPU overhead due to frequent polling

Given the same computational and data load, a multi-threaded program requires more resources than a program using multiple processes.

FALSE

The following is a correct statement to declare and initialize an integer pointer to a memory location that can contains 10 integer values: int *p = (int *) malloc(sizeof(int) * 10);

FALSE

Translation Lookaside Buffer is a translation mechanism developed in the operating systems that is capable of quickly calculate the physical memory address from virtual address

FALSE

Match the following disk scheduling algorithms with their corresponding descriptions.

FCFS - reasonable when load is low, long waiting time when load is high SSTF - minimizes arm movement and favors blocks in the middle tracks SCAN - serves request in one direction until done, then reverse LOOK - servers request in one direction until last request instead of going for full width of the disk.

Sort the order of execution for the following steps when the following command is executed from the shell: $ wc p3.c > newfile.txt Assume no error.

FIRST: finds out where wc is in the file system and prepares p3.c as an input to wc. SECOND: creates a new child process by calling fork(). The main process calls wait() to wait until the child process is finished. THIRD: within the new child process, closes the file descriptor to standard output and replaces with a file descriptor to newfile.txt FOURTH: The child process executes "wc p3.c" by calling exec().

How did modern operating systems facilitate processes' ability to perform restricted operations such as disk I/O, open network connections, etc?

Facilitate through hardware support of processor modes: user mode and kernel mode

What is the output of the final printf statement in the following program...

Golden Ram

Match the following solutions to the issue of large page table with their corresponding drawbacks.

INTERNAL FRAGMENTATION - Bigger page EXTERNAL FRAGMENTATION - Hybrid page table/logical segmentation MULTI-LEVEL PAGE TABLE - Increased address translation steps and implementation complexity

Match the following concepts in memory virtualization.

Pages - Virtual Address Space Page Frame - Physical Memory

Map the following sequence of process execution among tasks among the OS, HW, and the RP in correct order. You can assume that the OS has initialized the syscall table and HW remembered the address of syscall handlers.

Step 1: OS: Create task_struct in queue, allocate memory, setup stack, load stack with registers and PC. Call ret-from-trap(). Step 2: HW: Restore registers, move to user move, jump to main. Step 3: RP: Run main(), call syscall, and trap() into OS. Step 4: HW: save registers to kernel stack, jump to trap handler. Step 5: OS: Handles trap, do work of syscall, call ret-from-trap() Step 6: HW: restore registers from kernel stack, move to user mode, jump to pc Step 7: RP: return from main(), trap into exit() Step 8: OS: free memory of process and remove process from queue.

FSCK scans the whole disk, finds inconsistencies, and repairs them.

TRUE

The principle of journaling is to keep track of filesystem's write operations is about to do to the disk (read/write) so that inconsistencies can be avoided.

TRUE

In C, exec() is a family of functions responsible for executing a command w/ corresponding arguments based on the provided function parameters. Select all true statements about exec().

The new process is a replacement of the current process.

Given the following two programs... Given that the computer only has 1 CPU, we observe that: - All the printf statements in the child function of program 2 will print before the printf in the parent function. - The printf statements of the child and parent functions of program 1 are interleaved, with some printf statements from the parent printed first. This is because ...

The parent function of program 2 needs to perform I/O thus relinquishing the CPU to the child function of program 2.

Which of the following assumptions if failed will invalidate SJF/STCF?

The run time of each job is known.

How do modern operating systems support sharing of the CPU among processes?

Through hardware support of timer interrupt, which allows the OS to regain control and switch to a different running process

How do modern OS support sharing of CPU among processes?

Through the hardware support of timer interrupt, which allows the OS to regain control and switch to a different running process.

Why do we need multi-level indexing with indirect pointers

To leverage additional data blocks to contain inode pointers so that bigger data files can be supported.

Select all goals of memory virtualization.

Transparency Efficiency Protection

The wait() call can be used by the main process to wait on any child processes running.

True

Which of the following statements is correct regarding the memory hands-on demonstration results and the subsequent discussion.

Two processes use the same addressing scheme within their individual virtual address spaces OR Two process occupy separate physical memory space

Select all of the correct options (as per the lecture) describing how the OS helps the programs to run on a computer.

VIRTUALIZATION MANAGEMENT

Match the following data organization and access schemes with their appropriate definitions

block-based - inodes' pointers pointing to all fixed-size blocks containing the contents of a file extent-based - inodes' pointers specifying positions plus a fixed length (in blocks). linked-based - inodes pointer to the first block only. The first block contains a pointer to the second block and so on.

In file system, a superblock

contains information about the file system such as types, number of inodes and data blocks, and where the inode table begins.

Given an integer array A containing 5 numbers, 0, 2, 4, 6, and 8, which of the following is the correct statement to describe A + 3? - A is correctly declared as follows: int A[5] = {0,3,6,9,12}; - When printed out, the address of A is at 0x7fffc6b1cdd0

contains the address of A[3]

Match the following keywords with their corresponding definitions.

critical section - is a piece of code that accesses a shared resource. race condition - happens if multiple threads of execution attempt to update the shared data structure at the same time. indeterminate - is a scenario where only a single thread ever enters a critical section.

In memory, stack grows from low to high and heap grows from high to low.

false

When the operating system executes a default program (for example, nano), which process-spawning function does it call?

fork then exec

Given the following code, identify an error if one exists. ===== CODE BEGIN ===== #include <stdio.h> int pass_by_ref(int *i) {*i = (*i) * 2;return *i;} int main(int argc, char *argv[]) {int *i = (int *) malloc(sizeof(int)); i = 123;printf("Variable i before function call: %d\n", *i);printf("Function returns: %d\n", pass_by_ref(i));printf("Variable i after function call: %d\n", *i);return 0;} ===== CODE END =====

instead of i = 123, it should be *i = 123. Because i is declared as a pointer variable, we must implement it using an asterisk.

Select all correct declarations of an array of 5 integers.

int num[5] = {1,2,3,4,5}; int *num; num = (int *)malloc(20); int *num; num = (int *)Malloc(5*sizeof(int)); int *num; num = malloc(20);

Match the following tmux commands to their corresponding purposes.

ls = lists available sessions new -s = create a new session kill-session -t = kills session from main terminal ctrl-b then % = split into vertical panel ctrl-b then " = split into horizontal panel ctrl b then : = opens command line exit = shutdown session/panel from inside tmux ctrl-b then d = detatch from tmux and return to main terminal

Match the following file system crash scenarios with their possible issues.

only data block is updated - No inconsistency only inode is updated - Can read in garbage data and/or can overwrite data in data block only data bitmap is updated - space leak only inode and data bitmap is updated - read in garbage data without file system being aware that it is garbage data. only inode and data block are updated - Inconsistency between inode and bitmap leading to potential overwriting of good data. only data bitmap and data block are updated - Inconsistency between inode and bitmap, leading to file system unable to determine which file uses a allocated block.

Which of the following is the correct statement to point a pointer variable p of type integer to an integer variable x, given that x = 2? p and x are correctly declared and initialized as follow: int *p; int x = 2;

p = &x;

How did the modern operating systems facilitate processes ability to perform restricted operations such as disk I/O, open network connects, etc?

rely on user mode and kernel mode provided by hardware

Which action is being optimized by disk scheduling?

seek

Select one component that would enable the linkage between virtual interfaces and physical components for an operating system?

system calls

select one component that would enable linkage between virtual interfaces and physical components for an operating system.

system calls OR standard library

What is locality from a computer's perspective?

the patterns in computer programs' behaviors

CPU virtualization can give the illusion that there are more programs being run concurrently than the actual number of physical processors

true

Operating systems provide individual programs with their own private virtual address space. These virtual spaces are mapped to disjoint physical memory spaces.

true

The wait() call can be used by the main process to wait on any other child processes running in the operating system.

true


Set pelajaran terkait

Chapter 12 evolve questions cancer biology

View Set

Sociology: Social Stratification/Global Stratification

View Set

SB HW Ch Auditing Cash & Investments

View Set