Question Bank

Rows per page: 1025100

Showing 51–75

Computing Systems Operating Systems #15

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.

Computing Systems Operating Systems #16

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%

Computing Systems Operating Systems #17

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%

Computing Systems Operating Systems #18

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

Computing Systems Operating Systems #19

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

Computing Systems Operating Systems #20

Consider the following C code; how many child processes are created upon executing this program?

c
void main() { 
    fork(); 
    fork();  
    exit(); 
    fork(); 
}

2

3

4

8

Computing Systems Operating Systems #21

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

Computing Systems Operating Systems #22

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:

c
#define SIZE 5 
    while((n = read(fd, buffer, SIZE)) > 0) { 
    printf("%s\n",buffer); 
}

graduate

gradu

gradu ate

gradu atedu

Computing Systems Operating Systems #23

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?

c
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

Computing Systems Operating Systems #24

Which of the following is a function of an operating system?

Memory management

Virus protection

File management

Database management

Computing Systems Operating Systems #25

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

Computing Systems Operating Systems #26

Which system call is used to create a new process in Linux?

fork()

exec()

new()

createProcess()

Computing Systems Operating Systems #27

How can you change the permissions of a file in Linux?

chmod

chown

cp

mv

Computing Systems Operating Systems #28

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

Computing Systems Operating Systems #29

Which command is used to list the content of a directory?

ls

dir

list

show

Computing Systems Operating Systems #30

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

Discrete Structures and Algorithms Algorithms and Data Structures #1

Let f(n)f(n) = n2n^2, g(n)=ng(n) = n log n n , h(n)=sin(n)h(n) = sin(n). Which of the following statements is true? There may be more than one correct answer.

f=Θ(g)f = Θ(g).

h=o(g)h = o(g).

f=(h)f = Ω(h).

h=O(g)h = O(g).

Discrete Structures and Algorithms Algorithms and Data Structures #2

A recursive program satisfies equation T(n)=9T(n/3)+Θ(n2)T(n) = 9T(n/3) + Θ(n^2). What can we say about T(n)T(n)? There may be several correct answers.

T(n)=O(nT(n) = O(n log n)n).

T(n)=(n2)T(n) = Ω(n^2).

T(n)=Θ(n2)T(n) = Θ(n^2).

T(n)=O(n3)T(n) = O(n^3).

Discrete Structures and Algorithms Algorithms and Data Structures #3

In which of the following data structures does searching an item has worst-case complexity Θ(Θ(log n) n)? There may be more than one.

Linked lists.

Heaps.

Red-black trees.

Splay trees.

Discrete Structures and Algorithms Algorithms and Data Structures #4

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.

Discrete Structures and Algorithms Algorithms and Data Structures #5

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.

Discrete Structures and Algorithms Algorithms and Data Structures #6

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.

Discrete Structures and Algorithms Algorithms and Data Structures #7

Which of the following algorithms correctly computes the length of a longest increasing subsequence (LIS), problem and has complexity O(n2)O(n^2) ? 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.

Discrete Structures and Algorithms Algorithms and Data Structures #8

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 CkC_k, a longest sequence of courses that ends with CkC_k. Take the best such sequence over all k’s.

Discrete Structures and Algorithms Algorithms and Data Structures #9

A recursive algorithm reduces solving the problem on inputs of size n to solving four subproblems on size n/2n/2 and then combining the results. The combining step takes f(n)f(n) steps. We want our algorithm to have complexity O(n2)O(n^2). Which of the following are acceptable complexities for the combining step? There may be several right answers.

f(n)=O(1)f(n) = O(1).

f(n)=O(n)f(n) = O(n).

f(n)=O(nf(n) = O(n log n)n).

f(n)=Θ(n2)f(n) = Θ(n^2).