






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A mid-term exam for the computer science 15-410: operating systems course, held in spring 2004. The exam covers various topics such as definitions of operating system terms, interrupt handling, debugging a memory dump, and deadlock prevention. It includes multiple-choice questions, a timer interrupt handler analysis, a memory dump analysis, and a deadlock prevention task.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







think clearly about a problem, you will probably have time to write your answer legibly.
(b) 2 points Kernel stack
(c) 2 points Atomic instruction sequence
Consider the following attempt at a timer interrupt handler, perhaps written by a 410 student enamored of inline assembly language as opposed to stand-alone assembly language files.
static void timer_handler() { static unsigned int ticks_since_boot = 0;
asm("pusha");
tick(++ticks_since_boot);
if ((ticks_since_boot % (100100)) == 0) / debug printf every 100 seconds */ printf("Timer interrupt %d\n", ticks_since_boot);
outb(INT_CTL_REG, INT_CTL_DONE);
asm("popa"); asm("iret"); }
Please explain in detail the horrible thing that will happen when this code is run. Your explanation may include a clearly-drawn picture, but one is not required.
Given a dump of the stack memory and a symbol table, you will generate a stack trace as in Project 0. For each function in the trace, please write the name of the function and the names and values of the arguments. You may assume all strings are null terminated, and pointer arrays end with a NULL pointer. As was the case in Project 0, the first function you display will be the function which called the currently-running function (not the currently-running function itself). Your trace will be complete once you have displayed the invocation of the main function.
Here is a dump of memory, starting just before %ebp(0xbffff788) at the time of the breakpoint. For convenience, we have provided both hex and characters forms. Note, however, that the hex is presented in big-endian form by word, for readability, where the characters are in Intel-native little-endian, so the individual bytes may not line up between the two dumps.
3 2 1 0 7 6 5 4 b a 9 8 f e d c 0123456788abcdef 0xbffff780: 0x400162c0 0x00000002 0xbffff798 0x08048440 |.b.@........@...| 0xbffff790: 0x696e7500 0x000f3478 0xbffff7e8 0x08048379 |.unix4......y...| 0xbffff7a0: 0x0000000f 0x0000019a 0x40016000 0x00000003 |.........‘.@....| 0xbffff7b0: 0x61616161 0x61616161 0x61616161 0x61616161 |aaaaaaaaaaaaaaaa| 0xbffff7c0: 0xbfff0061 0x40007b31 0x0804818d 0x400129b0 |a...1{.@.....).@| 0xbffff7d0: 0x40006a8b 0x40024b43 0x002a8982 0x0005007f |.j.@CK.@..*.....| 0xbffff7e0: 0xbffff83c 0x400125c0 0xbffff898 0x0804835b |<....%.@....[...| 0xbffff7f0: 0xbffff870 0xbffff830 0x40027b7d 0x080481c7 |p...0...}{.@....| 0xbffff800: 0x276e6f64 0x6f662074 0x74656772 0x65687420 |don’t forget the| 0xbffff810: 0x6f6f6220 0x6572206b 0x74726f70 0x28205000 | book report.P (| 0xbffff820: 0x29100415 0x00000000 0xbffff8cc 0x01016000 |...).........‘..| 0xbffff830: 0x6920534f 0x77612073 0x6d6f7365 0x40002165 |OS is awesome!.@| 0xbffff840: 0x00000003 0x40016280 0x00313370 0xdeadbeef |.....b.@p31.....| 0xbffff850: 0x72617473 0x20646574 0x20656874 0x6e72656b |started the kern| 0xbffff860: 0x79206c65 0x003f7465 0x080481a6 0x0177ff8e |el yet?.......w.| 0xbffff870: 0x7464696d 0x736d7265 0x65726120 0x6e756620 |midterms are fun| 0xbffff880: 0x40016200 0x00000000 0x00000001 0xbffff8dc |.b.@............| 0xbffff890: 0x40009eb1 0x400069bf 0xbffff8e8 0x0804850b |[email protected].@........| 0xbffff8a0: 0xbffff8b0 0x00000000 0xbffff8d0 0x00000000 |................| 0xbffff8b0: 0xbffff8d8 0xbffff8dc 0xbffff8d4 0xbffff8d6 |................| 0xbffff8c0: 0xbffff8da 0xbffff8de 0x00000000 0x4001d9dc |...............@| 0xbffff8d0: 0x40021e6c 0x0062006f 0x00610066 0x0072006f |[email protected].| 0xbffff8e0: 0x40009da0 0x4001037f 0xbffff958 0x4002c4ed |...@...@X.......| 0xbffff8f0: 0x00000003 0xbffff900 0x400ed705 0xbffffae3 |...........@....| 0xbffff900: 0xbffff930 0xbffff920 0xbffff910 0x00000000 |0... ...........| 0xbffff910: 0x6d5f534f 0x65746469 0x535f6d72 0x40003430 |OS_midterm_S04.@| 0xbffff920: 0xbf003234 0x40009eb1 0x40012934 0x400162b0 |42.....@4)[email protected].@| 0xbffff930: 0x74732f2e 0x746b6361 0x00747365 0x4003ffd2 |./stacktest....@| 0xbffff940: 0xbffff9b0 0x40000d48 0x400125c0 0x00000003 |....H..@.%.@....| 0xbffff950: 0x00000000 0x4013dd30 0x00000000 0x08048271 |[email protected]|
It is time to build a house, and your task is to write an instruction manual for the carpenters. The instruction manual will take the form of a set of C functions. The carpenters must complete various jobs, each of which requires certain tools. These carpenters run a low-budget operation, so they have brought with them only one instance of each type of tool. The five tools are the screwdriver, the power drill, the hand drill, the drill chuck, and the clamp. You may assume that there are plenty of nails, screws, and drill bits. In order to use a tool, a carpenter must first acquire the tool. In order to complete the house on time it is very important that the carpenters do not find themselves in a deadlocked state! And now for some basic carpentry... In order to attach the right size drill bit to the power drill or to the hand drill you must also acquire the drill chuck. You must also use the drill chuck to detach the drill bit when a job is complete.
window_frame *build_window_frame(void){
doorknob *install_knob(void){
hinge *repair_hinge(void){
(b) 3 points Explain why deadlock is not possible.
(b) /* thread IDs */ int tid[] = {0, 0};
/* hello world message to be printed out */ char *greeting = "Hello world!\n";
/* the size of the stack for created threads */ #define STACK_SIZE 0x
void *foo(void *arg) { int my_tid, your_tid; char *msg;
/* get my tid */ my_tid = tid[(int)arg];
/* get the tid of the other thread */ your_tid = tid[((int)arg + 1) % 2];
if (my_tid < your_tid) { /* send hello world message to other thread */ thr_exit((void )greeting); } else { / receive the message and print it */ thr_join(your_tid, NULL, (void **)&msg); print("%s", msg); }
return NULL; }
/* This program prints "Hello world!\n" */ int main() { thr_init(STACK_SIZE);
/* create two threads */ tid[0] = thr_create(foo, 0); tid[1] = thr_create(foo, 1);
thr_exit(NULL); }