珠海免费网站建设,山西免费网站关键词优化排名,网站建立的具体步骤,wordpress怎么博客排版操作系统的基本功能和设计目标 1、 操作系统是一组 ____#xff08;单选#xff09; A、 文件管理程序 B、 资源管理程序 C、 中断处理程序 D、 设备管理程序 2、 以下哪项不是操作系统关心的主要问题#xff1f;#xff08;单选#xff09; A、 管理计算机裸机 B、 设计…操作系统的基本功能和设计目标 1、 操作系统是一组 ____单选 A、 文件管理程序 B、 资源管理程序 C、 中断处理程序 D、 设备管理程序 2、 以下哪项不是操作系统关心的主要问题单选 A、 管理计算机裸机 B、 设计、提供用户程序与计算机硬件系统的界面 C、 管理计算机系统资源 D、 高级程序设计语言的编译器 3、 下列关于操作系统的叙述正确的是单选 A、 操作系统是硬件和软件之间的接口 B、 操作系统是主机与外设之间的接口 C、 操作系统是用户与计算机之间的接口 D、 操作系统是源程序与目标程序之间的接口 4、 内存管理的主要任务有多选 A、 物理内存的分配和回收 B、 虚拟地址到物理地址的映射 C、 地址转换的加速 D、 突破物理内存限制 5、 除了易用性、高效性、可靠性和可扩展性这四个设计目标现代操作系统还应考虑能效性。以下哪项不属于操作系统改善计算机能耗的途径单选 A、 根据工作负载调整CPU频率 B、 采用模块化的结构设计 C、 采用动态电压和频率缩放技术 D、 休眠或关闭部分空闲设备如磁盘 系统函数调用基础 1、 以下不是用来分配内存的函数的是(单选) A、 realloc() B、 malloc() C、 free() D、 calloc() 2、 lseek()中第三个参数的值为0表示单选 A、 文件读写指针当前位置 B、 文件开始位置 C、 文件结束位置 D、 都不是 3、 下面更改文件命令只能更改符号连接的目标文件的权限的命令是单选 A、 chgrp B、 chown C、 chmod D、 以上都不对 4、 下面关于ftell()函数成功调用说法不正确的是(单选) A、 返回读写指针当前相对文件起始位置的位移量 B、 返回读写指针当前相对文件结束位置的位移量 C、 会清除流结束标志 D、 会撤销已调用ungetc对流的影响 5、 以下函数中表示从某流中读取一个字符但该函数不带参数表示从标准输入流中读字符的函数是单选 A、 getc B、 gets C、 fgec D、 getchar 6、 在函数fopen()中文件打开模式中不是可读写的方式打开文件模式是单选 A、 r B、 r C、 a D、 w 7、 格式化输出可把格式化数据输出到标准输出、指定文件及字符缓冲区。其中 函数是将格式化数据输出到指定大小的字符缓冲区单选 A、 sprintf B、 snprintf C、 fprintf D、 printf 文件系统基础 1、 比较文件的差异要用到的命令是以下哪一种单选 A、 diff B、 cat C、 wc D、 head 2、 存放设备文件的相关文件目录是单选 A、 /dev B、 /etc C、 /lib D、 /bin 3、 rm命令表示什么单选 A、 文件复制命令 B、 移动文件命令 C、 文件内容统计命令 D、 文件删除命令 4、 在openEuler系统中用户文件描述符0表示单选 A、 标准输出设备文件描述符 B、 标准输入设备文件描述符 C、 管道文件描述符 D、 标准错误输出设备文件描述符 5、 在使用 mkdir命令创建新的目录时在其父目录不存在时先创建父目录的选项是单选 A、 -d B、 -m C、 -p D、 -f 6、 执行命令“chmod orw myfile”后myfile文件的权限变化为单选 A、 所有用户都可读写myfile文件 B、 其他用户可读写myfile文件 C、 同组用户可读写myfile文件 D、 文件所有者读写myfile文件 进程基础知识 1、 临界区是指并发进程中涉及共享变量的。 A、 程序段 B、 管理信息区 C、 公共数据区 D、 信息存储区 2、 下列有关fork()函数返回值说法错误的是() A、 函数成功返回时一次返回两个值错误返回时为-1 B、 返回值等于0表示子进程 C、 返回值大于0表示父进程 D、 大于0返回值为父进程的PID号 3、 下面程序的输出是什么() #include stdio.h#include unistd.hint main(int argc, char** argv){if(fork() 0){printf(hello);}else{printf(world);}return 0;} A、 helloworld B、 wordhello C、 hello D、 不确定 4、 下面说法不正确的是( ) A、 管道和命名管道是最早进程间通信机制之一 B、 消息队列是将消息按队列的方式组织成的链表每个消息都是其中的一个节点 C、 进程创建一般由create函数完成 D、 共享内存和消息都是由Linux内核来管理和分配资源 5、 关于SIGCHLD信号说法错误的是 A、 在子进程退出时会向父进程发送该信号 B、 需要及时处理SIGCHLD防止僵尸进程 C、 SIGCHLD信号的默认处理方式是忽略 D、 由于SIGCHLD信号默认方式是忽略所以在代码中不需要手动设置SIGCHLD信息的处理方式也不会产生僵尸进程 6、 下列哪种通信方式只能用于具有亲缘关系进程之间的通信() A、 匿名管道 B、 消息队列 C、 共享内存 D、 命名管道 Linux操作系统
第1关Linux初体验
编程要求 根据右侧窗口命令行内的提示在Begin - End区域内进行命令行语句补充具体任务如下 切换当前目录到根目录 列出根目录下所有文件和文件夹(包括隐藏文件/文件夹)。 #!/bin/bash #在以下部分写出完成任务的命令 #*********begin*********# cd cd .. ls -a #********* end *********# 第2关Linux常用命令
编程要求 根据右侧窗口命令行内的提示在Begin - End区域内进行代码补充具体任务如下 在当前目录下新建一个新的文件(名称为newfile);在当前目录下新建一个新的文件夹(名称为newdir);将newfile文件复制一份到newdir目录下并命名为newfileCpy。 #!/bin/bash #在以下部分写出完成任务的命令 #*********begin*********# touch newfile mkdir newdir cp newfile newdir/newfileCpy #********* end *********# 第3关Linux 查询命令帮助语句
编程要求 根据右侧窗口命令行内的提示在Begin - End区域内进行代码补充具体任务如下 使用man查询C库中的fopen函数使用方法。 #!/bin/bash #在以下部分写出完成任务的命令 #*********begin*********# man 3 fopen #********* end *********# Linux之进程管理一 第1关获取进程常见属性
编程要求 本关的编程任务是补全右侧代码片段中Begin至End中间的代码具体要求如下 补全getProcInfo函数用于获取当前进程ID和其父进程ID(提示将结果存放在procIDInfo结构体中)。 #include unistd.h
#include sys/types.h
#include stdio.h/*********************** pid: 当前进程ID* ppid: 父进程ID
***********************/
struct procIDInfo
{pid_t pid;pid_t ppid;
};/************************* 返回值: 需要被打开的目录路径
*************************/
struct procIDInfo getProcInfo()
{struct procIDInfo ret; //存放进程ID信息并返回/********** BEGIN **********/ret.pid getpid();ret.ppid getppid();/********** END **********/return ret;
}第2关进程创建操作-fork
编程要求 本关的编程任务是补全右侧代码片段中Begin至End中间的代码具体要求如下 补全createProcess函数使用fork函数创建进程并在子进程中输出Children字符串在父进程中输出Parent字符串。(注意不要在createProcess函数中使用exit函数或者return来退出程序)。 #include unistd.h
#include sys/types.h
#include stdio.h
#include string.h
#include errno.h/************************* 提示: 不要在子进程或父进程中使用exit函数或者return来退出程序
*************************/
void createProcess()
{/********** BEGIN **********/pid_t pid;pid fork();if (pid0)printf(Children);else if(pid0)printf(Parent);/********** END **********/
}第3关进程创建操作-vfork
编程要求 本关的编程任务是补全右侧代码片段中Begin至End中间的代码具体要求如下 补全createProcess函数使用vfork函数创建进程并在子进程中输出Children字符串(提示需要换行)在父进程中输出Parent字符串(提示需要换行)。 #include unistd.h
#include sys/types.h
#include stdio.h
#include string.h
#include errno.h
#include stdlib.h/************************* 提示: 不要在子进程中使用return来退出程序
*************************/
void createProcess()
{/********** BEGIN **********/pid_t pid;pid vfork();if(pid0){printf(Children\n);}else if(pid 0){printf(Parent\n);}/********** END **********/exit(0);
}第4关进程终止
编程要求 本关的编程任务是补全右侧代码片段中Begin至End中间的代码具体要求如下 补全exitProcess函数使用atexit函数注册一个函数在注册函数中打印出当前进程的ID号。 #include unistd.h
#include sys/types.h
#include stdlib.h
#include stdio.h/************************* 提示: 用户需要在exitProcess函数中使用atexit函数注册一个自定义函数并在自定义函数中打印出当前进程ID号
*************************/
void exitProcess()
{/********** BEGIN **********/void exit(){printf(%d\n,getpid());}if(atexit(exit)!0)printf(调用atexit函数错误\n);/********** END **********/
}生产者消费者问题实践
第1关生产者消费者问题实践
编程要求 请参考生产者线程的函数代码实现消费者线程的函数代码将Consumer()函数补充完整。 #include stdio.h
#include stdlib.h
#include unistd.h
#include pthread.h
#include semaphore.h#define SIZE 10int in 0;
int out 0;
int buffer[SIZE];
sem_t empty;
sem_t full;
pthread_mutex_t mutex;void *Producer()
{int nextp 0;int i 0;for(; i 10; i){ int time rand() % 10 1;usleep(time*100000); sem_wait(empty); pthread_mutex_lock(mutex);nextp nextp 1;buffer[in] nextp;printf(Produce one message:%d\n, nextp);fflush(stdout);//printf后请一定调用这句刷新输出缓存in (in 1) % SIZE;pthread_mutex_unlock(mutex); //互斥锁解锁sem_post(full);}
}void *Consumer()
{//请补充消费者线程函数代码int nextc0;int i0;for (;i10;i){sem_wait(full); //等待缓冲区非空pthread_mutex_lock(mutex); //加锁nextc buffer[out];printf(Consume one message:%d\n,nextc);fflush(stdout);out(out1)%SIZE;pthread_mutex_unlock(mutex); //解锁sem_post(empty); //增加一个空缓冲区}
}int main()
{ sem_init(empty, 0, 10); //信号量初始化最多容纳10条消息容纳了10条生产者将不会生产消息sem_init(full, 0, 0); pthread_mutex_init(mutex, NULL); //互斥锁初始化 pthread_t producid; pthread_t consumid; pthread_create(producid, NULL, Producer, NULL); //创建生产者线程 pthread_create(consumid, NULL, Consumer, NULL); //创建消费者线程 pthread_join(producid, NULL); pthread_join(consumid, NULL); sem_destroy(empty); //信号量的销毁sem_destroy(full); pthread_mutex_destroy(mutex); //互斥锁的销毁return 0;
}
第2关进程互斥和同步 编程要求 请参考爸爸线程的函数代码实现儿子和女儿线程的函数代码将Son()函数和Daughter()函数补充完整。 #include stdio.h
#include stdlib.h
#include unistd.h
#include semaphore.h
#include pthread.h
sem_t apple;
sem_t orange;
sem_t empty;
pthread_mutex_t mutex;void *Dad()
{int nextp 0;int i 0;for(i 0; i 10; i){int time rand() % 10 1; //随机使程序睡眠0点几秒usleep(time*100000); sem_wait(empty); pthread_mutex_lock(mutex);if(nextp 0){printf(爸爸放入了一个苹果\n);}else{printf(爸爸放入了一个桔子\n);}fflush(stdout);pthread_mutex_unlock(mutex); //互斥锁解锁if(nextp 0){sem_post(apple);}else{sem_post(orange);} nextp 1 - nextp; }
}void *Daughter()
{while(1){int time rand() % 10 1; //随机使程序睡眠0点几秒usleep(time * 100000); sem_wait(apple); pthread_mutex_lock(mutex);printf(女儿取了一个苹果\n) ;fflush(stdout);pthread_mutex_unlock(mutex); //互斥锁解锁sem_post(empty);}
}
void *Son()
{//请添加儿子线程的函数代码while (1) {int timerand()%101; //随机使程序睡眠0点几秒usleep(time*100000);sem_wait(orange);pthread_mutex_lock(mutex);printf(儿子取了一个桔子\n);fflush(stdout);pthread_mutex_unlock(mutex); //互斥锁解锁sem_post(empty);}
}
int main()
{ sem_init(empty, 0, 5); //信号量初始化sem_init(orange, 0, 0);sem_init(apple, 0, 0); pthread_mutex_init(mutex, NULL); //互斥锁初始化 pthread_t dadid; pthread_t daughterid;pthread_t sonid; pthread_create(dadid, NULL, Dad, NULL); //创建爸爸线程 pthread_create(daughterid, NULL, Daughter, NULL); //创建女儿线程pthread_create(sonid, NULL, Son, NULL); //创建儿子线程 pthread_join(daughterid, NULL);pthread_join(sonid, NULL); sem_destroy(empty); //信号量的销毁sem_destroy(apple);sem_destroy(orange); pthread_mutex_destroy(mutex); //互斥锁的销毁return 0;
}