CS332 Test 2

0.0(0)
studied byStudied by 1 person
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/106

flashcard set

Earn XP

Description and Tags

Last updated 6:05 PM on 3/4/23
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

107 Terms

1
New cards
What does a File Descriptor do?
It keeps track of the open files within linux, each file is labeled by a number
2
New cards
T/F: File Descriptors can be negative ints
False
3
New cards
What is the standard I/O stream
The standard I/O stream allows you to open a file in read, write or append modes
4
New cards
What is the input stream?
The I/O stream that allows for the program to open a file.
5
New cards
What is the output stream?
The I/O stream that allows a program to write to a file
6
New cards
What does the function 'getc()' do?
It lets you get the next character from an input stream
7
New cards
What does the function getline() do?
It lets you get an entire line from the input stream, it also stores the address of the buffer
8
New cards
T/F: the getline() returns the terminating null byte ('\\0')
False
9
New cards
What does getdelim() do?
It gets the characters present upto the delimiter
10
New cards
T/F: the getdelim() returns the terminating null byte ('\\0')
False
11
New cards
What does the function gets() do?
It reads a line from the input stream and stores it into the string pointed to by a str
12
New cards
When does the function gets() stop?
It stops whenever a newline ('\\n') or the end of file is reached
13
New cards
To avoid buffer overflow, one should use ______ instead of gets() in order to restrict how many characters are read
fgets()
14
New cards
strtok is responsible for?
extracting tokens from strings. It breaks down a string into a string of zero or more nonempty tokens
15
New cards
atoi, atol, atoll are all responsible for?
converting a string to an integer
16
New cards
atof is responsible for?
converting a string to a double
17
New cards
strdup is responsible for?
duplicating a string
18
New cards
A program in execution is also known as a _____
process
19
New cards
An instance of a running program is also known as _____
process
20
New cards
The entity that can be assigned to, and executed on, a processor is also known as ______
process
21
New cards
A unit of activity characterized by a single sequential thread of execution, a current state, and an associated set of system resources can also be known as ______
process
22
New cards
When a program is loaded into the memory, it can be divided in the sections of
stack

heap

text

data
23
New cards
The data section of memory in a x86-64 linux machine is responsible for?
holding statically allocated data, such as global vars, static vars, and string constants
24
New cards
The heap section of memory in a x86-64 linux machine is responsible for?
it holds variables/objects that are dynamically allocated whenever you use things such as malloc, calloc, new
25
New cards
The stack section of memory in a x86-64 linux machine is responsible for?
holding runtime variables such as local variables
26
New cards
The text section of memory in a x86-64 linux machine is responsible for?
holding executable machine instructions and it is read-only
27
New cards
when a program is executing, the process can be uniquely characterized by how many number of elements?
8 elements
28
New cards
What are the 8 elements that can uniquely characterize a program process
identifier

state

priority

program counter

memory pointers

context data

I/O status information

accounting information
29
New cards
process spawning is the act of?
when an OS creates a process at the explicit request of another process
30
New cards
the parent process is known as the
original process
31
New cards
T/F: when a parent process creates a new process, it is a copy of the parent process
true
32
New cards
T/F: In process termination, there must be a means for a process to indicate it's completion
true
33
New cards
T/F: In process termination, there can be a batch job that includes a HALT instruction or an explicit OS service call for termination
true
34
New cards
For an interactive application, what indicates the process is completed?
The actions of the user, such as logging off, quitting an application, etc
35
New cards
The two modes of execution are ___________ mode and ___________ mode
user, system
36
New cards
User programs generally execute in ______ mode
user
37
New cards
T/F: System mode is an elevated mode of running executables
true
38
New cards
PID stand for?
process ID
39
New cards
the OS tracks processes through a _________
five digit ID (aka, PID)
40
New cards
T/F: Each process in the system has a unique PID
true
41
New cards
the 'ps' command showcases?
a list of running processes
42
New cards
a background process is a process that?
\n runs in the background, frees the terminal for user control but continues to run without user input
43
New cards
a foreground process is a process that?
runs in the foreground, it attachs directly to the current view of the user for the terminal thus a user can interact with it directly
44
New cards
how do you bring a background process to the foreground?
fg %
45
New cards
how do you send a foreground process to the background
suspend the process, then use bg or if the program is not suspended you can use bg %
46
New cards
how do you start a program in the background?
use '&', &
47
New cards
how does fork() work
it creates a new process by duplicating the calling process. The new process is referred to as the child process. The calling process is referred to as the parent process.
48
New cards
the newly created process after running fork() is called?
the child process
49
New cards
T/F: after the parent process creates the child process, the parent process continues with its normal execution
true
50
New cards
what happens to a child process if the parent process terminates before it
it becomes a zombie process
51
New cards
what is a zombie process
a process without a parent process
52
New cards
the wait() function allows for the child process to exit prior to the parent process by ___________ the parent process
suspending
53
New cards
when do you use waitpid() vs using wait() to watch for a change of state in a child process
whenever you have more than one child process and you want to track a specific one
54
New cards
the exec() family of function is responsible for
replacing the current process image with a new process image
55
New cards
what does the execl() function take as an argument
the execl() function take the full pathname of executable along with a pointer to an array of characters for each argument
56
New cards
There are _______ classes of exec functions
two
57
New cards
The two classes of exec functions are ____ and ____
l versions, v versions
58
New cards
What's the difference between l versions and v versions for the exec() family of functions
the l versions take a list as an argument while the v version takes a vector as the arguments
59
New cards
T/F: The l versions of functions within the exec family end their list of arguments with a null pointer
true
60
New cards
T/F: The v versions of functions within the exec family end their list of arguments with a null pointer
false
61
New cards
Functions that have a p at the beginning of the name use the ____________ as the first argument
filename
62
New cards
Functions without the a p at the beginning of the name use _____________ as the first argument
pathname
63
New cards
T/F: if the filename contains a slash character (/) it is considered as a pathname
true
64
New cards
function that end in e have an additional argument, a point to an array of pointers to the _________________ strings
environment
65
New cards
The environment is defined by the _________________ variables
environment
66
New cards
The environment variables can be set by __________ or ____________ or _______________ or ___________
The system

The user

The shell

Programs that loads other programs
67
New cards
In unix shells the act of initialization refers to
the setup of the environment, using environment variables to customize how the system works and the behavior of applications on the system
68
New cards
T/F: Linux and Unix are the same
False
69
New cards
Linux is derived from _______
unix
70
New cards
T/F: Linux refers to a complete OS
False
71
New cards
Linux is just a _______
kernel
72
New cards
This Linux kernel is generally packaged in Linux ___________ which thereby makes it a ___________ ____
distributions , complete, OS
73
New cards
The three states a user process in a linux environment are __________ , ____________ or ____________
foreground

background

suspended
74
New cards
interactive applications can only run in the _____________ state
foreground
75
New cards
if you are running a non-interactive process, it is best you run it in the ________
background
76
New cards
to execute a program in the background, you use the following syntax
&
77
New cards
when you start a program in the background, the shell will return the
The background process number and the corresponding process identifier
78
New cards
To view background processes you run the _____ command
jobs
79
New cards
to suspend a foreground process you press
control-z
80
New cards
background processes that start when the system start and end when the system ends are called?
daemons
81
New cards
generally daemon process end in which character ?
d
82
New cards
to terminate a foreground process you press
control-c
83
New cards
to terminate a background process you can _______ or you can _______
bring to foreground and use control-c

\
use the kill command
84
New cards
the argument for the kill command is the
PID of the process you would like to terminate
85
New cards
the ps command is responsible for
reporting a snapshot of the current process
86
New cards
By default, ps lists processes for the
current user associated with the terminal that invoked it
87
New cards
the ps snapshot includes
the process ID (PID), the terminal associated with the process (TTY), the cumulative CPU time in hh:mm:ss format (TIME), and the executable name (CMD)
88
New cards
The pstree command is used to display the ______ _______
process tree
89
New cards
the process tree is
a tree view of the processes running sorted by PID
90
New cards
the ______ command does the same thing as the ps command
top
91
New cards
what's the difference between the top command and the ps command
the top command showcases a real-time update while ps showcases a snapshot
92
New cards
a virtual file system that is created by the OS at system boot time to provide an interface between the kernel space and user space is called the
proc file system
93
New cards
the /proc file system is responsible for
providing information of processes currently running on the system and tools such as ps use this to display information about these processes
94
New cards
For files that contain strings separated with null characters you have to use the ________ command to display the contents of such files correctly
strings
95
New cards
the unit of dispatching is reffered to as a ______________ or ________________
thread, lightweight process
96
New cards
the unit of resource ownership is reffered to as a ___________ or _________
process, task
97
New cards
multithreading is the ability of an OS to
support multiple, concurrent paths of execution within a single process
98
New cards
T/F: each thread belongs to exactly one process and no thread can exist outside a process
true
99
New cards
each thread represents ___________
a separate flow of control
100
New cards
concurrency
the ability of different parts or units of a program to be run out-of-order or in partial order without affecting the final outcome

Explore top flashcards

Onc lec 3
Updated 435d ago
flashcards Flashcards (112)
SAT Vocab Lesson 7-8
Updated 321d ago
flashcards Flashcards (30)
Uni
Updated 450d ago
flashcards Flashcards (42)
POS lesson 15
Updated 1074d ago
flashcards Flashcards (29)
Festival Neck Pain
Updated 1099d ago
flashcards Flashcards (81)
Unit 5: Hereditary
Updated 1044d ago
flashcards Flashcards (62)
Onc lec 3
Updated 435d ago
flashcards Flashcards (112)
SAT Vocab Lesson 7-8
Updated 321d ago
flashcards Flashcards (30)
Uni
Updated 450d ago
flashcards Flashcards (42)
POS lesson 15
Updated 1074d ago
flashcards Flashcards (29)
Festival Neck Pain
Updated 1099d ago
flashcards Flashcards (81)
Unit 5: Hereditary
Updated 1044d ago
flashcards Flashcards (62)