Dollinger review 2

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

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

50 Terms

1
New cards
In cloud computing, what does PaaS stand for?
Platform as a Service
2
New cards
Global variables are automatically initialized to zero. True or False?
True
3
New cards
Understand the C++ memory model.
Four segments: text (code), data/BSS (globals and statics), heap, stack
4
New cards

Where are statics stored?

BSS for unitialized or zero initialized, else data

5
New cards
Which of the 4 segments holds the machine instructions the CPU executes?
text/code
6
New cards
Which segment is where dynamic memory allocation takes place?
Heap
7
New cards
Which segment stores info saved on each function call, including the address to return to?
Stack
8
New cards
Items in which segment live for the whole program unless the program deletes them?
Heap
9
New cards
Danger of a postfix operation (like i++) on a variable that appears elsewhere in the same expression: if the modification and the other use are unsequenced, what is the behavior called?
Undefined behavior
10
New cards
When a C++ program starts, how many standard file descriptors are already open?
3: 0 = stdin, 1 = stdout, 2 = stderr
11
New cards

Given a statement with freopen, what does it do and what are the arguments?

Redirects an existing stream to a file. filename, mode, and stream.

12
New cards
After a fork, what are the differences between parent and child?
Fork return value, process ID, parent process ID, and separate memory
13
New cards
After a fork, what is the numeric return value for the child?
0
14
New cards
What does fork return when it fails?
-1
15
New cards
Three simple forks in a row: including the initial parent, how many processes?
8
16
New cards
if (fork()) fork(); including the initial parent, how many processes?
3
17
New cards
A fork, then an if with another fork inside and a cout inside the if: how many times does the string display, and how many lines?
2 times on 2 lines
18
New cards
A for loop from 1 to 3 (not including 3) with a fork inside: total processes?
2^number of iterations = 2^2 = 4 processes
19
New cards

Which statement is NOT true about fork?

the child has the same PID, fork creates two children, the child shares the parent's memory, fork returns 0 to the parent

20
New cards
After a fork, the PID of the parent process is always 0. True or False?
False
21
New cards

Does fork return true or false?

0 = false, else true

22
New cards
What does dup do?
Duplicates an existing file descriptor
23
New cards
Given an array of 2 holding a pipe, which index do you use to read?
0
24
New cards
Given an array of 2 holding a pipe, which index do you use to write?
1
25
New cards

Which statement is NOT true about pipes?

works across a network, two-way communication

26
New cards
In a program using named pipes, a correct blocking open waits until a corresponding open occurs on the other side. True or False?
True
27
New cards
When using named pipes, the client and server must use a known named pipe to establish communication. True or False?
True
28
New cards
Correct order of named pipe operations (given mkfifo, chmod, open, pathname)
Pathname -> mkfifo -> chmod -> open
29
New cards
What does execvp do?
Overlays (replaces) the current process with a new program.
30
New cards
For a socket client and server, what must both know in common? (True/False version: both must know the port address)
The IP address, port number, and protocol
31
New cards
Correct order of client socket operations
Socket, connect, read/write, close
32
New cards
Which API is NOT used in typical client socket code but is used in a server?
Bind, listen, or accept
33
New cards
Which IPC mechanism works across a network to various machines? (sockets, named pipes, pipes)
Sockets
34
New cards
Which item is NOT related to a socket mechanism? (protocols, IP address, port numbers, ...)
Pick the pipe-related or process-related one.
35
New cards
Sockets cannot be used to communicate between processes on the same machine. True or False?
False
36
New cards
Correct order of server socket operations
Socket, bind, listen, accept, read/write
37
New cards

When setting up an Internet socket, what does SOCK_STREAM indicate?

TCP protocol

38
New cards
The socket loopback IP address is?
127.0.0.1
39
New cards
pthread_create takes the thread's start routine as its third parameter and only one argument for that routine as its last parameter. True or False?
True
40
New cards
The P thread start command must be used to start the thread. True or False?
False
41
New cards
To build a C++ program with pthreads on Linux, you include pthread.h in the source and use the g++ build flag -pthread. True or False?
True
42
New cards

What does each thread have unique to itself?

Stack, registers, PC, stack pointer, and thread ID

43
New cards
Which memory segment is NOT shared by threads of the same program?
Stack
44
New cards
Threads improve performance because they can execute for times greater than the time allocated for the process. True or False?
False
45
New cards
A critical code section is designated by the application to allow what?
Only one thread at a time to run that code
46
New cards
What do we call the lock/unlock that lets one thread through a critical section at a time?
A mutex (mutual exclusion lock)
47
New cards
Which pthread call waits for a started thread to complete?
Join (pthread_join)
48
New cards

Which statement is NOT true about threads?

each thread has its own heap, each thread gets a new PID

49
New cards
Thread-safe code means multiple threads can go through it at once without problems. Is cout thread safe in the sense that output from different threads cannot interleave? True or False?
False
50
New cards
Linux is what type of operating system? (preemptive or not, time shared or not)
Preemptive and time shared