Question Bank
You are asked to design an interactive operating system for users, whose main purpose is playing back YouTube videos. Which of the following choices should you make?
To ensure videos will play back smoothly, you should consider scheduling computationallyintensive processes with higher priority as opposed to I/O-bound processes.
To ensure network buffering happens fast enough, you should consider scheduling I/O-bound processes with higher priority as opposed to CPU-bound processes.
If the CPU is too slow to render the video smoothly, your OS must focus heavily on I/O to improve playback.
If the CPU is capable of rendering the video at 60fps smoothly, your OS no longer needs to do any type of I/O at all.
None of the above.
A computer has 6 GB of RAM, of which the operating system occupies 1 GB. The processes are all 512 MB and have the same characteristics. If the goal is 98% CPU utilization, what is the maximum I/O wait that can be tolerated?
2%
80%
50%
67%
Consider a multiprogrammed system with a degree of 10 (i.e., ten programs in memory at the same time). Assume that each process spends 60% of its time waiting for I/O. What will be the CPU utilization?
∼ 100%
∼ 60%
∼ 40%
∼ 10%
In a system with threads, is there one stack per thread or one stack per process when different user-level threads and kernel-level threads are used?
one stack per thread for both cases
one stack per thread for user-level threads while kernel-level threads are using one stack per process
one stack per thread for kernel-level threads while user-level threads are using one stack per process
one stack per process for both cases
Let’s consider a manufacturing assembly line where various workers perform different tasks to assemble a product:
(1) Component suppliers who supply the necessary components for the assembly process,
(2) Assemblers that receive the components and assemble them into the final product,
(3) Inspectors, who check the quality of the finished products to ensure they meet the required standards,
(4) Packagers, who receive the inspected products and package them for shipping or distribution,
(5) Shippers that receive the packaged products and prepare them for transportation to customers or retailers.
By relating this model to processes in UNIX, what form of interprocess communication best describes this interaction?
fork functions to create processes
signals
pipes
threads
Consider the following C code; how many child processes are created upon executing this program?
void main() {
fork();
fork();
exit();
fork();
}2
3
4
8
For the following decimal virtual addresses 20202, compute the virtual page number and offset for a 4-KB page:
16, 3818
4, 3818
5, 202
20, 202
The application below reads from a file containing only one string, namely "graduate". What will be the message printed on the screen if the read is successful:
#define SIZE 5
while((n = read(fd, buffer, SIZE)) > 0) {
printf("%s\n",buffer);
}graduate
gradu
gradu ate
gradu atedu
The following code snippet should use pipes in order to communicate between the child and the parent process. Is there something wrong with the pipe mechanism from the code snippet below?
int pipe_fd[2];
char buffer[512];
pid_t pid=fork();
if(pid<0){
perror("error");
exit(1);
}
if(pid==0){
write(pipe_fd[1],buffer,sizeof(buffer));
}
else{
close(pipe_fd[0]);
read(pipe_fd[0],buffer,sizeof(buffer));
close(pipe_fd[1]);
printf("%s\n",buffer);
wait(NULL);
}the pipe is not opened
the pipe ends are not closed in the child
the pipe ends are correctly closed in the parent
the pipe ends are incorrectly closed in the parent
Which of the following is a function of an operating system?
Memory management
Virus protection
File management
Database management
A group of operating system designers is considering ways to reduce the number of backing stores needed in their new operating system. The team leader has suggested not bothering to save the program text in the swap area at all but just paging it directly from the binary file whenever it is needed. Under what conditions, if any, does this idea work for the program text?
it works for the program if the program cannot be modified
it works for the data, if the data cannot be modified
it works if the data is modified and the program is not
it works if the program is modified and the data is not modified
Which system call is used to create a new process in Linux?
fork()
exec()
new()
createProcess()
How can you change the permissions of a file in Linux?
chmod
chown
cp
mv
In a Linux system, what is the primary function of the cgroups (control groups) feature?
Managing system logs
Grouping user accounts
Limiting, prioritizing, and isolating the resource usage (CPU, memory, disk I/O, etc.) of process groups
Controlling access to system files
Which command is used to list the content of a directory?
ls
dir
list
show
How does the exec() family of functions differ from fork() ?
exec() creates a new process, while fork() does not
exec() replaces the current process image with a new one
fork() is used to execute programs
There is no difference
Let = , log , . Which of the following statements is true? There may be more than one correct answer.
.
.
.
.
A recursive program satisfies equation . What can we say about ? There may be several correct answers.
log .
.
.
.
In which of the following data structures does searching an item has worst-case complexity log ? There may be more than one.
Linked lists.
Heaps.
Red-black trees.
Splay trees.
Which binary tree traversal can be used to list all numbers in a binary search tree in sorted order? There may be more than one correct answer.
Breadth-first search.
Preorder.
Inorder.
Postorder.
Which of the following sorting methods is not a comparison-based sort? There may be more than one right answer.
Quicksort.
Radix Sort.
Insertion Sort.
HeapSort.
Which of the following problems can be solved by an algorithm with complexity O(n log n)? There may be more than one right answer.
Given a list L of n integers, find three numbers x, y, z ∈ L (if they exist) such that x+y = z.
Given a list L of n integers and a target value z, find two numbers in x, y ∈ L (if they exist) such that x + y = z.
Given a list L of n integers and a target value z, find two numbers in x, y ∈ L (if they exist) such that x − y = z.
Given a list L of n integers, find three numbers x, y, z ∈ L (if they exist) such that x+y+z = 0.
Which of the following algorithms correctly computes the length of a longest increasing subsequence (LIS), problem and has complexity ? There may be more than one right answer.
Put the numbers in the list in piles of decreasing numbers. A new number is added greedily to the first pile it can be added to, or starts a new pile if it cannot be added to any existing pile. The length of the LIS is the number of piles.
We run a greedy algorithm, maintaining a list of increasing numbers. When processing a new number we add it to the LIS if possible, we discard it and proceed otherwise.
We run a backtracking algorithm, maintaining the list of the biggest LIS seen so far. When encountering a new number we add it to the sequence if possible. If not we backtrack and continue with the next sequence.
We solve the problem by dynamic programming, computing the length of the LIS subsequence ending in a given term ak of the sequence. We then take the maximum of the so-computed LIS’s.
We are given a list of courses, each with a start and an end time. We only have one room and want to schedule as many of these courses as possible. Which of the following algorithms finds an optimal solution? There may be more than one correct answer.
Greedily choose the shortest courses.
Greedily choose courses that start first.
Greedily choose courses that end first.
Sort courses by their endtime. Compute, for each course , a longest sequence of courses that ends with . Take the best such sequence over all k’s.
A recursive algorithm reduces solving the problem on inputs of size n to solving four subproblems on size and then combining the results. The combining step takes steps. We want our algorithm to have complexity . Which of the following are acceptable complexities for the combining step? There may be several right answers.
.
.
log .
.