CMU Final SP 2011 Flashcards

1
Q

Which of the following is a legitimate difference between IA-32 and x86-64? (a)Buffer overflow exploits are impossible under x86-64.
(b) IA-32 has caller-and callee-saved register conventions, while x86-64 does not.
(c)Under x86-64, any instructions that take 32-bit operands are illegal.
(d)None of the above.

A

(d)None of the above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is the best justification for using the middle bits of an address as the set index into a cache rather than the most significant bits?
(a) Indexing with the most significant bits would necessitate a smaller cache than is possible with middle-bit indexing, resulting in generally worse cache performance.
(b) It
is impossible to design a system that uses the most significant bits of an address as the set index.
(c) The process of determining whether a cache access will result in a hit or a miss is faster using middle-bit indexing.
(d)A program with good spatial locality is likely to make more efficient use of the cache with middle-bit indexing than with high-bit indexing.

A

(d)A program with good spatial locality is likely to make more efficient use of the cache with middle-bit indexing than with high-bit indexing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following is not true about POSIX-style signals?
(a) Certain signals cannot be blocked. (b)A process can send a signal to itself. (c)A signal handler executing as the result of a received signal can never be interrupted by another incoming signal. (d) Signals can only be delivered when returning from system mode.

A

(c)A signal handler executing as the result of a received signal can never be interrupted by another incoming signal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is not a benefit of virtual memory?
(a) It allows the virtual address space to be larger than the physical address space
(b)No process can accidentally access the memory of another process
(c) The TLB is more effective since without it dereferencing a virtual address now requires two or more memory accesses
(d)Different processes can have overlapping virtual address spaces without conflict

A

(c) The TLB is more effective since without it dereferencing a virtual address now requires two or more memory accesses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which of the following is a difference between blocking and ignoring a signal? (a)Once a blocked signal is unblocked, it will be handled by the process. A signal that comes while it is being ignored will never be handled.
(b) SIGSTOP and SIGINT can be ignored, but not blocked.
(c) Ignoring a signal only causes it to have no effect, while blocking a signal returns the signal to its sender. (d)None of the above

A

(a)Once a blocked signal is unblocked, it will be handled by the process. A signal that comes while it is being ignored will never be handled.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where is the first argument to a function located in 32-bit assembly code, immediately after the call instruction is executed?
(a)%ebp+0x4
(b)%ebp-0x4
(c)%esp+0x4
(d)%exp-0x4

A

(c)%esp+0x4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Consider the following piece of code, where out.txt’s contents are“abc”: int main(int argc, char** argv) { intfd=open(“out.txt”,O_RDWR); charstr[]=”xyz”; charc; write(fd1,str,1); read(fd1,&c,1); write(fd1,&c,1); return0; } What is the contents of out.txt after the code is run? Assume all system calls succeed.
(a) xbb
(b) xba
(c) xac
(d) boat

A

(a) xbb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following is the best reason to choose Fast CGI over CGI?
(a) Superior support by web servers like Apache
(b) Lower process creation costs
(c) Lower process communication costs (d)Better process locality (all tasks can be executed locally)

A

(b) Lower process creation costs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which of the following system calls can fail due to a network failure?
(a) socket(…)
(b) listen(…)
(c) bind(…)
(d) gethostbyname(…)

A

(d) gethostbyname(…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following are copied on fork and preserved on exec?
(a)Global variables.
(b) File descriptor tables.
(c)Open file entry structs.
(d)None of the above.

A

(b) File descriptor tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why would the kernel designer opt
for a 2-level page table when a full 2-level page table takes up more memory than a full 1-level page table?
(a) 2-level tables can translate virtual addresses faster.
(b) 2-level tables can reference more memory than 1 level tables.
(c)Most of the time, a 2-level page table will take up less memory than a 1 level page table.
(d) They wouldn’t. Adding more tables offers no advantages.

A

(c)Most of the time, a 2-level page table will take up less memory than a 1 level page table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What section of memory holds the assembly for printf?
(a) Stack
(b)Kernel memory
(c) Shared libraries
(d)Heap

A

(c) Shared libraries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Every thread has its own:
(a)Heap
(b)Global values
(c) Stack
(d) Text data

A

(c) Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is gethostbyname not threadsafe?
(a)Only one thread at a time can do a DNS lookup
(b) It doesn’t have a mutex around it
(c) It returns a pointer to global shared memory
(d) It shares instructions with other threads

A

(c) It returns a pointer to global shared memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If a page table on a 32-bit system is 2KB in size, how many entries does it contain?
(a) 2048
(b) 1024
(c) 512
(d) 256

A

(c) 512

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the function of the TLB?
(a)Caches data
(b)Caches instructions
(c)Caches translation of virtual addresses (d) Translates physical addresses to virtual addresses

A

(c)Caches translation of virtual addresses

17
Q

What is distinctive about super scalar processors?
(a)Can run at frequencies over 3.5GHz
(b)Can address over 4GB of memory
(c)Can perform more than one instruction per cycle
(d)Can have more than 2 levels of cache
(e)Have more than one core per processor

A

(c)Can perform more than one instruction per cycle

18
Q

True/False: When requested to send 20 bytes over a network socket, execution will block until all 20 bytes have been sent.
(a) True
(b) False

A

(b) False

19
Q

True/False: When printf returns, the programmer cannot be guaranteed that the data has appeared on the user’s terminal.
(a) True
(b) False

A

(a) True

20
Q

Which of the following tools would you first use to debug an application which is exiting with the error “Segmentation fault”?
(a) gdb
(b) strace
(c) strings
(d) objdump

A

(a) gdb

21
Q

Which of the following tools would you first use to debug a network application that never appears to accept any connections?
(a) gdb
(b) strace
(c) objdump
(d) valgrind

A

(b) strace

22
Q

Which of the following tools would you first use to debug an application which is exiting with a glibc error: double free detected?
(a) gdb
(b) strace
(c) wireshark
(d) valgrind

A

(d) valgrind

23
Q

A 256-byte 4-way set associative cache with 16 byte blocks has
(a) 4sets
(b) 16sets
(c) 64sets
(d)Nosets

A

(a) 4sets

24
Q

Imagine a floating point format with no sign bit, one exponent bit, and one fraction bit. Which of the following is not a number?
(a) 00
(b) 01
(c) 10
(d) 11
(e)Noneoftheabove

A

(d) 11