CMU Final 2010 Flashcards
Which of the following is NOT a universal property of reader-writer locks?
(a) Readers can only look at a shared item; writers can also modify it.
(b) If a writer has access to the item, then no other thread also has access. (c)Any number of readers can read the item at the same time.
(d)A writer waiting for an RWlock will get preference over subsequent read requests.
(d)A writer waiting for an RWlock will get preference over subsequent read requests.
Starvation (in relation to threads) refers to:
(a) A thread waiting for a lock indefinitely.
(b)A semaphore that gets locked but the thread never unlocks it after use.
(c)A thread is spawned but never joins the main thread when finished.
(d)A process fails to spawn a new thread because it’s hit the maximum number of threads allowed.
(a) A thread waiting for a lock indefinitely.
Consider the following two blocks of code, found in separate files: /main.c/ inti=0; intmain() { foo(); return0; }
What will happen when you attempt to compile, link, and run this code?
(a) It will fail to compile.
(b) It will fail to link.
(c) It will raise a segmentation fault.
(d) It will print “0”.
(e) It will print “1”.
(f) It will sometimes print “0” and sometimes print “1”.
(b) It will fail to link.
Which of the following is an example of external fragmentation?
(a)A malloc’ed block needs to be padded for alignment purposes.
(b)A user writes data to a part of the heap that isn’t the payload of a malloc’ed block.
(c) There are many disjoint free blocks in the heap.
(d)A user malloc’s some heap space and never frees it.
(c) There are many disjoint free blocks in the heap.
Which of the following is NOT the default action for any signal?
(a) The process terminates all of its children.
(b) The process terminates and dumps core.
(c) The process terminates.
(d) The process stops until restarted by a SIGCONT signal.
(a) The process terminates all of its children.
Which of the following is FALSE concerning x86-64 architecture?
(a)A double is 64 bits long.
(b) Registers are 64 bits long.
(c) Pointers are 64 bits long.
(d) Pointers point to locations in memory that are multiples of 64 bits apart.
(d) Pointers point to locations in memory that are multiples of 64 bits apart.
Consider the following block of code: int main() { int a[213];
inti ;
//intj=15;
for(i=0; i< 213;i++)
a[i]=i;
return 0;
a[0]=-1;
}
Which of the following instances of ‘bad style’ is present?
(a)Dead code.
(b)Magic numbers.
(c) Poor indentation.
(d)All of the above.
(d)All of the above.
Consider the following structure declarations on a 64-bit Linux machine. struct RECORD{ long value2; double value; char tag[3]; }; struct NODE{ int ref_count; struct RECORD record; union{ double big_number; char string[12]; } mix; }; Also, a global variable named my node is declared as follows: struct NODE my_node; If the address of my node is 0x6008e0, what is the value of &mynode.record.tag[1]?
(a) 0x6008f8
(b) 0x6008fa
(c) 0x6008f9
(d) 0x6008f5
(e) 0x6008f1
(c) 0x6008f9