嵌入式Linux应用程序开发期末考试题库及答案 联系客服

发布时间 : 星期一 文章嵌入式Linux应用程序开发期末考试题库及答案更新完毕开始阅读3dcd4929f01dc281e53af088

____通信是指利用多条数据传输线将一个资料的各位同时传送。 并行

在Linux中,实现文件上锁的函数有lock和____。 FCNTL

Linux中最常见最基础的操作对象是____。 文件

当用户在系统中键入命令执行一个程序的时候,它将启动一个____。 进程

系统调度的单位____。 进程

____包含了进程的描述信息、控制信息以及资源信息,它是进程的一个静态描述。 进程控制块

进程执行态说明该进程正在执行,即进程正在占用____。 CPU

Linux系统是一个____进程的系统。

Daemon进程即通常所说的____进程,是Linux中的后台服务进程。。 守护

在Linux中使用____函数创建一个新进程。 FORK

fork函数调用后出现父进程与子进程,其中____的返回值为0。 子进程

____函数族就提供了一个在进程中启动另一个程序执行的方法。 EXEC

exit()函数与_exit()函数最大的区别就在于____函数在exit系统调用之前要检查文件的打开情况,并将文件缓冲区中的内容写回文件。 EXIT()

____函数是用于使父进程阻塞,直到一个子进程结束或者该进程接到了一个指定的信号为止。 WAIT

在Linux中,所有的孤儿进程自动由____进程收养。 INIT

____函数用于创建一个新的会话,并担任该会话组的组长。 SETSID

系统日志文件位于/____目录下。 VAR/LOG

TCP/IP的协议参考模型包括网络接口层、____、传输层和应用层。 网络层

TCP为协议参考模型包中____层的协议。 传输

____对话通过三次握手来完成初始化。 TCP

对数据要求高可靠性的应用应选择____协议。 TCP

Linux中的网络编程通过____接口来进行。 SOCKET

SOCK_DGRAM为____套接字。 数据报

在实验中,实验平台采用的CPU为Intel____处理器。 XSCALL

在内核更新与加载实验中,设置的串口波特率为____。 115200

在内核更新与加载实验中,设置的串口数据位为____。 8

在内核更新与加载实验中,设置的数据流控制为____。 无

在内核更新与加载实验中,设置的数据停止位为____。 1

在内核更新与加载实验中,实验平台上使用的串口为COM____。 1

在内核更新与加载实验中,内核映像的后缀部分为____。 ZIMAGE

在内核更新与加载实验中,通过____将内核映像下载到实验平台。

USB

压缩的内核映像通常名为____。 ZIMAGE

未压缩的内核映像通常名为____。 VMLINUX

操作系统内核运行之前运行的一段程序称为____。 BOOTLOADER

程序设计题

下面的程序打开一个文件,并设置该文件权限为0666。请选出应填写在空白处的选项。 int main(void) { int fd; if((fd = open(\O_CREAT | O_TRUNC | O_WRONLY , 0666 ))<0) { perror(\ exit(1); } else { printf(\file: hello.c %d\\n\ } if( __________ ) { perror(\ exit(1); } else printf(\ exit(0); }

A、open(fd) > 0 B、open(fd) < 0 C、close(fd) > 0 D、close(fd) < 0 4

下面的程序打开一个文件,写入字符串“Hello! I'm writing to this file!”,使用lseek 函数将文件指针移到文件开始处,并读出10个字节并将其打印出来。请选出应填写在空白处的选项。 int main(void) { int i,fd,size,len; char *buf=\ char buf_r[10]; len = strlen(buf); if((fd = open(\O_RDWR,0666 ))<0) { perror(\ exit(1); } else printf(\file:hello.c %d\\n\ if((size = write( fd, buf, len)) < 0) { perror(\ exit(1); } else printf(\ lseek( __________ ); if((size = read( fd, buf_r, 10))<0) { perror(\ exit(1); } else printf(\form file:%s\\n\ if( close(fd) < 0 ) { perror(\ exit(1); } else printf(\ exit(0); } A、fd, 0, SEEK_CUR B、fd, 0, SEEK_END C、fd, 0, SEEK_SET 3

下面的程序说明文件记录锁函数。首先给flock 结构体的对应位赋相应值,接着使用两次fcntl函数分别用于给相关文件上锁和判断文件是否可以上锁,这里用到的cmd值分别为F_SETLK 和F_GETLK。请选出应填写在空白处的选项。 void lock_set(int fd, int type) { struct flock lock; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len =0; while(1) { lock.l_type = type; if( __________ ) { if( lock.l_type == F_RDLCK ) printf(\lock set by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\lock set by %d\\n\ else if( lock.l_type == F_UNLCK ) printf(\lock by %d\\n\ return; } fcntl(fd, F_GETLK, &lock); if(lock.l_type != F_UNLCK) { if( lock.l_type == F_RDLCK ) printf(\lock already set by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\ getchar(); } } } A、(fcntl(fd, F_SETLK, &lock)) < 0 B、(fcntl(fd, F_SETLK, &lock)) == 0 C、(fcntl(fd, F_SETLK, &lock)) > 0 2

下面的程序测试文件的写入锁。首先创建hello文件,之后对其上写入锁,最后释放写入锁。请选出应填写在空白处的选项。 int main(void) { int fd; fd=open(\| O_CREAT, 0666); if(fd < 0) { perror(\ exit(1); } __________; getchar(); lock_set(fd, F_UNLCK); getchar(); close(fd); exit(0); } void lock_set(int fd, int type) { struct flock lock; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len =0; while(1) { lock.l_type = type; if((fcntl(fd, F_SETLK, &lock)) == 0 ) { if( lock.l_type == F_RDLCK ) printf(\

by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\lock set by %d\\n\ else if( lock.l_type == F_UNLCK ) printf(\lock by %d\\n\ return; } fcntl(fd, F_GETLK,&lock); if(lock.l_type != F_UNLCK) { if( lock.l_type == F_RDLCK ) printf(\lock already set by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\set by %d\\n\ getchar(); } } } A、lock_set(fd, F_RDLCK) B、lock_set(fd, F_WRLCK) C、lock_set(fd, O_RDONLY) D、lock_set(fd, O_WRONLY) 2

下面的程序测试文件的读取锁。首先创建hello文件,之后对其上读取锁,最后释放读取锁。请选出应填写在空白处的选项。 int main(void) { int fd; fd=open(\| O_CREAT, 0666); if(fd <0) { perror(\ exit(1); } __________; getchar(); lock_set(fd, F_UNLCK); getchar(); close(fd); exit(0); } void lock_set(int fd, int type) { struct flock lock; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len =0; while(1) { lock.l_type = type; if((fcntl(fd, F_SETLK, &lock)) == 0 ) { if( lock.l_type == F_RDLCK ) printf(\by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\lock set by %d\\n\ else if( lock.l_type == F_UNLCK ) printf(\lock by %d\\n\ return; } fcntl(fd, F_GETLK,&lock); if(lock.l_type != F_UNLCK) { if( lock.l_type == F_RDLCK ) printf(\lock already set by %d\\n\ else if( lock.l_type == F_WRLCK ) printf(\set by %d\\n\ getchar(); } } } A、lock_set(fd, F_RDLCK) B、lock_set(fd, F_WRLCK) C、lock_set(fd, O_RDONLY) D、lock_set(fd, O_WRONLY) 1

下面的程序打开一个文件,写入字符串并读出。请选出应填写在空白处的选项。 int main() {

FILE

*stream;

char

s[3]={'a','b','c'};

stream=fopen(\

i=fwrite( __________ ); printf(\ fclose(stream); } A、s,sizeof(char),nmemb,stream B、s,char,nmemb,fd

C、s,sizeof(char),nmemb,FILE D、s,char,nmemb,FILE 4

下面的程序获得当前进程的PID。请选出应填写在空白处的选项。 int main() { printf(\A、getpid() B、getppid()