CSE381 Exam

0.0(0)
Studied by 3 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/248

flashcard set

Earn XP

Last updated 12:40 AM on 3/9/23
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

249 Terms

1
New cards
A Direct Memory Access (DMA) is a hardware device that is used to
Move data from a device into main memory (RAM)
2
New cards
The Master Boot Record (MBR) is stored on a Hard Disk Drive (HDD) in
First sector
3
New cards
At startup, device drivers for an Hard Disk Drive (HDD) are typically loaded by
The OS after the kernel has already been loaded from the HDD
4
New cards
On modern CPUs, the OS-kernel(s) typically run in a privileged mode called
Ring 0
5
New cards
In a modern quad-core, dual-CPU server the number of OS-kernels(s) running on the server would be
1
6
New cards
The virtua memory subsystem of an OS also manages
The main memory (RAM)
7
New cards
In a 32-bit microprocessor, the virtual memory for a process is limited to 4 GB. Consequently the total virtual memory that the OS can access and manage is limited to
Amount of space reserved for virtual memory on secondary storage
8
New cards
The first system call that is typically reported for a program by strace is
Execve
9
New cards
The process ID (PID) for the first init process started by Linus is
1
10
New cards
The most concise definition of a mutable pointer (pointer can be changed to point elsewhere) to a constant integer value would be
cont int\* ip;
11
New cards
The result of the expression 5 + 3 \* 2 is
11
12
New cards
The value stored in the variable result due to the following C/C++ language statement (same behavior in Java too) would be:

\
int result = 3 % -2;
1
13
New cards
Which one of the following is a valid and a real infinite loop?
for (;;);
14
New cards
Which one of the following is not a functionality of a conventional operating system
Manage caches on a CPU
15
New cards
The minimum number of cores and CPUs that are required to run a multi-tasking operating system like Linux is
One CPU with 1 core
16
New cards
A computer with 1 GB of RAM is synonymous to a computer with
1024 MB of RAM
17
New cards
The fastest storage device on a conventional CPU are
Registers
18
New cards
The expansion of RAM is
Random Access Memory
19
New cards
An application what would significantly benefit by running in batch processing mode would be
A simple program to multiply several large matrices
20
New cards
The most suitable operating system for gaming consoles that run one game for a player wuold be
Multi-tasking operating system
21
New cards
The minimum number of threads that are present in a standard process created by modern operating systems would be
1
22
New cards
Assume a process consists of 3 threads, namely T1, T2, and T3 and the threads were started in the order T1, T2, and T3. The order in which the 3 threads will join is:
The order in which threads will join is not deterministic
23
New cards
Which one of the following resources is not shared by default between multiple threads
Program stack
24
New cards
Given an 8 core CPU the maximum number of threads that can be created in one single process is
Depends on the maximum threads supported by OS
25
New cards
A good example of a Task Parallel application would be
Converting a vide to MPEG4/H264, OGV, and MOV format
26
New cards
A good example of a Data Parallel application would be
Converting each pixel in a photo to black-n-white
27
New cards
The number of monitors that are necessary to ensure MT-safe access to the SharedValue shown in the code fragment below would be:
The number of monitors that are necessary to ensure MT-safe access to the SharedValue shown in the code fragment below would be:
0
28
New cards
Suitable command (or command-chain) to list just the processes associated with your login-id
ps -fea | grep raodm
29
New cards
Which one of the following resource is not managed by the operating system
Caches on the CPU
30
New cards
The minimum number of cores and CPUs that are required to run a multi-tasking operating system like Linux is
One CPU with 1 core
31
New cards
The expansion for BIOS is
Basic Input Output System
32
New cards
An application that would significantly benefit by running in batch processing mode would be
A program to compute the billionth digit of the irrational constant pi
33
New cards
The most suitable operating system for a smart phone would be
Multi-processing operating system
34
New cards
A suitable operating system design for a micro System on a Chip (SoC) device is
Monolithic design
35
New cards
The BIOS Parameter Block (BPB) for a FAT-12 file system is stored on disk in the
The Master Boot Record in the middle of the boot loader code
36
New cards
The smallest unit of data that can be physically read from spinning storage media is
A sector
37
New cards
The first process that is started by the Linux operating system is called
Init
38
New cards
In Linux, when a program is run as a background process, it
It runs normally, but cannot read input from the terminal
39
New cards
The -Wall option to the GNU compilers (gcc/g++) is used to
Generate warnings that are potential sources of errors in the program
40
New cards
In OS terminology, “device drivers” are
Software used to interface OS to hardware
41
New cards
What is the expansion of the acronym API?
Application Program Interface
42
New cards
Environment and energy are the greatest challenges facing humanity. Given that nearly 25% of the global energy (by some estimates) is consumed by technology, it is imperative that we try to use the most energy and resource-efficient programming language. Which one of the following programming languages is the most energy-efficient?
C++
43
New cards
Which one of the following is not a system?
A data communication network
44
New cards
The primary motivation for systems programming is to
Develop software such as operating systems, web-servers, etc
45
New cards
In the following debugger button in VS-Code, clicking button 1 causes the debugger to:
In the following debugger button in VS-Code, clicking button 1 causes the debugger to:
Continue running until next breakpoint
46
New cards
In the following debugger buttons in VS-Code, clicking button 4 causes the debugger to:
In the following debugger buttons in VS-Code, clicking button 4 causes the debugger to:
Run until end of the method
47
New cards
In the following debugger buttons in VS-Code, the button to step over to the next line of code is
2
48
New cards
The following for-loop that iterates over a string works:

\
std::string str = "some data";

for (int i = 0; (i < str.size()); i++) {

str\[i\] = '\*';

}

\
However, the compiler generates a warning:

warning: comparison between signed and unsigned integer expressions

\
The correct solution to fix this issue would be
Change int to size_t
49
New cards
std::string str = "123456789";

std::string **s** = str.substr(2, 3);
345
50
New cards
Assume the following code is used to read user inputs.

int i;

std::string str;

std::cin >> i >> i >> str;

Assume the user enters the following input. The data that will be stored in the variable str will be:

10 20 testing
testing
51
New cards
Assume the following code is used to read user inputs.

std::string str;

std::cin >> std::quoted(str);

Assume the user enters the following input. The data that will be stored in the variable str will be:

this is a test
This
52
New cards
Given the following code fragment,

int main(int argc, char \*argv\[\]) { std::cout << argv\[0\] << std::endl; }

The value in argv\[0\] will be:
Path to the executable file name
53
New cards
The correct/preferred signature for a function named doIt, that accepts a string that the function is not going to modify, would be:
void doIt(const std::string& str)
54
New cards
Assume the following code

void doIt(std::string s);

The method is using:
Pass by value
55
New cards
Assume user inputs 3 numbers, each separated by a blank space (*e.g.*, "123 45 8345" or "8345 123 45", etc.). The input is stored in a string object named str. The __simplest way__ to read the 2nd integer from the string str into the integer i would be to:
std::istringstream is(str);

is >> i >> i;
56
New cards
In order to write/overwrite data to a file, the correct stream to use is
std::ofstream
57
New cards
Given the following code fragment, the 2nd line of code that access an entry:

std::unordered_map
Adds an entry with key/index "test" with value 22
58
New cards
Given the following definition for an unordered_map, what is the preferred approach for inserting/adding a value into the unordered_map?

using StrIntMap = std::unordered_map
wordNum\["three"\] = 10;
59
New cards
The preferred method to add an element to the end of a vector is
push_back
60
New cards
The correct approach/syntax to insert an element x at the ith index position in a vector vec is
vec.insert(std::begin(vec) + i, x);
61
New cards
The correct approach/syntax to delete/remove an element x at the ith index position in an vector vec is
vec.erase(std::begin(vec) + i);
62
New cards
Given two strings str1 and str2, the correct/preferred way to check to see if the two strings are equal (*i.e.*, have exactly the same sequence of characters) is:
str1 == str2
63
New cards
The value stored in variable s shown below is (Note: sub-string in C++ has different parameters than Java)

std::string str = "123456789";

std::string **s** = str.substr(7);
89
64
New cards
Assume the following code

void doIt(int& i);

The method is using:
Pass by reference
65
New cards
The correct approach/method to check if a given value exists in an unordered_map is to use
Use find() method
66
New cards
In a multiprocessing OS, the process of permitting a different process to use the CPU is called
Context switching
67
New cards
What is the expansion of the acronym GNU
GNU’s Not Unix
68
New cards
The page tables in a TLB are switched by an OS as part of
Context switching
69
New cards
What does the term PPID stand for?
Parent Process Identifier
70
New cards
In GNU/Linux users are organized into groups. A key capability enabled by the use of groups is
Ease sharing files between users
71
New cards
In GNU/Linux, system configuration files are typically stored in
/etc
72
New cards
The fastest storage on a computer are
CPU Registers
73
New cards
What is the expansion of the acronym CPU?
Central Processing Unit
74
New cards
The Translation Lookaside Buffer (TLB) is used to
Map virtual addresses to real addresses
75
New cards
The uid of root is
0
76
New cards
In GNU/Linus what is uid?
A unique number associated with each user
77
New cards
A syscall is
Function call to the OS
78
New cards
The last system call that a process always makes in called
exit_group
79
New cards
A key reason why system calls are a bit slower is because
Switching to privileged ring takes time
80
New cards
What is POSIX?
Standard set of APIs an OS must support
81
New cards
The first stage boot loader of an OS is loaded by
BIOS
82
New cards
What is the expansion of the acronym BIOS?
Basic Input Output System
83
New cards
What is the commonly used boot loaded for Linus called?
grub
84
New cards
The line of code that may experience a Running → Ready transition would be
The line of code that may experience a Running → Ready transition would be
Line number 4
85
New cards
Given the process tree below, the command kill -9 137 will kill processes
Given the process tree below, the command kill -9 137 will kill processes
137, 127, and 147
86
New cards
The line of code that would cause a Running → Waiting transition would be
The line of code that would cause a Running → Waiting transition would be
Line number 6
87
New cards
Assume you are running a simple console program via the Linux terminal. An easy way to abort the program would be to
Control+C
88
New cards
A malicious program (aka virus) is running on a computer consuming resources. In which type of multitasking would the user experience the most inconvenience?
Non-preemptive multitasking
89
New cards
XBox and PS4 are designed to run resource-intensive games. They run one game at a time so that the game can monopolize resources like CPU time, memory, GPU, etc. A good multitasking approach for such application is
Non-preemptive multitasking
90
New cards
Which of the following sequence of fork system calls correctly create the process hierarchy shown below. Assume the code starts running in the process at the root of the hierarchy:
Which of the following sequence of fork system calls correctly create the process hierarchy shown below. Assume the code starts running in the process at the root of the hierarchy:
if (fork() == 0) {

if (fork() == 0) {

fork(); } }
91
New cards
The return value of the fork (system call) is
Zero in the child process
92
New cards
The exit code of a program is interpreted as
Zero indicates success and non-zero indicates errors
93
New cards
Which of the following sequence of fork system calls correctly create the process hierarchy shown below. Assume the code starts running in the process at the root of the hierarchy:
Which of the following sequence of fork system calls correctly create the process hierarchy shown below. Assume the code starts running in the process at the root of the hierarchy:
fork();

fork();
94
New cards
The exit code of a program is
Return value from main function
95
New cards
Assume the following method is being run by a process. Excluding this parent process (i.e., the process that is initially running the method below), the total number of child processes created would be:

void forkyMon() {

if (fork() > 0) {

fork(); } }
2
96
New cards
First study the following code fragment that creates 2 file streams:

std::ofstream log("log.txt");

int pid = fork();

std::ifstream info("input_data.txt");

Given the above code fragment, which of the following applies to the log stream?
The log stream is shared by both parent and child processes
97
New cards
Given the following line of code below, which of the following statements is true:

auto pid = fork();
The virtual memory address of pid is the same in the parent and child
98
New cards
After successfully starting the specified program the execvp command
Never returns to the calling process
99
New cards
The exit code of a child process is
The return value from the main function of the child proess
100
New cards
Assume the forkNexec method below is a helper method that – runs a given program in a child process while returning PID of the child in the parent process. What would be the estimated runtime of the sleepy method?

// Helper method \n int forkNexec(std::vector argList); \n \n void sleepy() {

int pid1 = forkNexec({"sleep", "3"}); \n int pid2 = forkNexec({"sleep", "2"});

waitpid(pid1, nullptr, 0); \n waitpid(pid2, nullptr, 0); }
3 seconds