311143040_系统级编程(A闭)

上传人:油条 文档编号:1683983 上传时间:2017-07-05 格式:PDF 页数:9 大小:374.20KB
返回 下载 相关 举报
311143040_系统级编程(A闭)_第1页
第1页 / 共9页
311143040_系统级编程(A闭)_第2页
第2页 / 共9页
311143040_系统级编程(A闭)_第3页
第3页 / 共9页
311143040_系统级编程(A闭)_第4页
第4页 / 共9页
311143040_系统级编程(A闭)_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《311143040_系统级编程(A闭)》由会员分享,可在线阅读,更多相关《311143040_系统级编程(A闭)(9页珍藏版)》请在金锄头文库上搜索。

1、 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 s

2、ystem 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 prog

3、ram 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 f

4、ollowing 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 object

5、s 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

6、 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

7、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 t

8、he 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.

9、 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 on

10、e. 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

11、-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 s

12、tatic_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

13、: 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 th

14、e 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-add

15、ress = (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)

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 其它文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号