资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
1 / 9 311143040 系统级编程 ( A闭 ) 2015-2016-1 Problem 1( 40 Points) : Multiple choice questions 1 In Visual C+, a Win32 Console Application is A. the status window of the Visual C+ environment B. the simplest type of application Visual C+ can generate C. a program that is able to control the operating system of a windows computer D. built by using sophisticated Application Wizards 2 A branch instruction A. unconditionally sets the program counter to its operand B. sets the program counter to one of two possible values C. sets the program counter to one of many possible values D. increases the program counter by a fixed amount 3 In c, assuming that an int takes 4 bytes, how many bytes are required to represent the following array? int a12; A. 44 B. 52 C. 12 D. 48 4 How is 46 (decimal) represented in an 8-bit 2s complement binary format? A. 11110 B. 101100 C. 1000110 D. 101110 5 Consider the following function. int factorial(int n) if (n = 1) return n; return n * factorial(n - 1); How many activation records are popped when it is invoked by the expression factorial(4)? A. 0 B. 1 C. 4 D. 5 6 Which of the following features apply to standard heap allocation in c? i. the size of heap objects must be known at compile time. ii. heap memory must be explicitly allocated. 2 / 9 311143040 系统级编程 ( A闭 ) 2015-2016-1 iii. heap memory is deallocated when a function returns. A. and only. B. only. C. only. D. and . 7 In c, when a struct is freed, A. only those pointers within the struct that point into the heap are freed automatically. B. any pointers within the struct are also freed automatically. C. a destructor function is called automatically to clean up. D. no pointers within the struct are freed automatically. 8 Which statement is true? A. Using the rst-t algorithm on a free list that is ordered according to increasing block sizes is equivalent to using the best-t algorithm. B. For the best-t method, the list of free blocks should be ordered according to increasing memory addresses C. The best-t method chooses the largest free block into which the requested segment ts. D. Using the rst-t algorithm on a free list that is ordered according to decreasing block sizes results in low performance for allocations, but avoids external fragmentation. 9 Wall time measures A. the time a program spends waiting for input and output. B. the user time plus the system time. C. idle time. D. the total duration of a programs execution. 10 Which of the following approaches towards optimizing programs is most advisable? A. optimize after all functions are written and debugged. B. optimize main() first. C. optimize as you go: make sure every function is optimized before writing the next one. D. optimize the more complex functions first. 11 Which of the following levels of a typical memory hierarchy transfers data in chunks of biggest size? A. they all transfer one byte at a time. B. main memory disk. C. cpu registers cache. D. cache main memory. 3 / 9 311143040 系统级编程 ( A闭 ) 2015-2016-1 12 In IA32 or x86, which exception is used to implement system call A. interrupt B. trap C. fault D. Abort 13 which variable will be put into bss? int printf( const char* format, . ); int global_init_var = 84; int global_uninit_var; void func1( int i ) printf( %dn, i); int main(void) static int static_var = 85; static int static_var2; int a = 1; int b; func1( static_var + static_var2 + a + b ); return a; A. a and b B. static_var C. global_init_var D. global_uninit_var 14 Consider the following fragments from two versions of a program. version a version b / version a for (i = 0 ; i * Max ops: 6 * / int getByte(int x, int n) /* * isLess - if x * Max ops: 24 */ int isLess(int x, int y) 8 / 9 311143040 系统级编程 ( A闭 ) 2015-2016-1 Problem 4 (10 Points): Are there any memory errors in the following program? If so, identify all of the errors and provide a corrected code fragment to alleviate the problem. 1 char *foo() char *copy; char *mystring = Pink Red; copy = malloc(strlen(mystring); return strcpy(copy, mystring); 2 typedef struct char *name; int age; char *address; int phone; Person; void my_function() Person *p = (Person *) malloc(sizeof(Person); p-name = (char *) malloc(M); . p-address = (char *) malloc(N); . free(p); Problem 5 (10 Points): Dynamic Memory Allocation. Please write the Pseudo code to describe the basic idea of Mark/Sweep GC. Problem 6 (12 Points): Cache memories. Consider the following matrix transpose function typedef int array22; void transpose(array dst, array src) int i, j; for (j = 0; j 2; j+) 9 / 9 311143040 系统级编程 ( A闭 ) 2015-2016-1 for (i = 0; i 2; i+) dstij = srcji; running on a hypothetical machine with the following properties: sizeof(int) = 4. The src array starts at address 0 and the dst array starts at address 16 (decimal)
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号