最后一次考试了 小海螺
预祝大家都能过!
简答题(7题考4题)
- 嵌入式系统的开发流程
- 系统需求分析
- 体系结构设计
- 硬件/软件协同设计
- 系统集成
- 完成测试并形成产品
- 中断处理的6个步骤
- 禁止其他中断
- 保存上下文
- 中断处理程序
- 中断服务程序
- 恢复上下文
- 允许新的中断
- Linux内核的5个功能
- 进程管理
- 内存管理
- 文件管理
- 设备控制
- 网络功能
- 常见的文件类型
- 普通文件类型
- 目录文件类型
- 块设备文件类型
- 字符设备类型
- 套接字文件类型
- 管道文件类型
- 链接文件类型。
- GCC编译的各个阶段及生成文件类型
- 预处理 (.c文件=>.i)
- 编译(.i文件=>.s)
- 汇编(.s文件=>.o)
- 链接(.o文件=>.elf/.out)
- 驱动程序编译进内核的一般步骤
- 创建Kconfig配置文件
- 编写编译驱动程序的Makefile文件
- 修改上层目录中的Kconfig和Makefile文件
- 运行内核配置界面menuconfig,生成编译内核的配置文件.config
- 运行内核源代码根目录下的Makefile或build文件,编译内核
- Linux中进程间通信方式有哪些
- 管道及有名管道
- 共享内存
- 消息队列
- 信号
- 信号量
- 套接字
程序分析和程序设计
-
Makefile 文件程序 p77 题目不固定 放两个例题
- 例题:Makefile给出main.c、mytool1.h、mytool1.c、mytool2.h、mytool2.c的依赖关系
main:main.o mytool1.o mytool2.o gcc -o main main.o mytool1.o mytool2.o main.o:main.c gcc -c main.c mytool1.o:mytool1.c mytool1.h gcc -c mytool1.c mytool2.o:mytool2.c mytool2.h gcc -c mytool2.c
- 例题:
sum:ex_sum.o mysum.o gcc ex_sum.o mysum.o -o sum ex_sum.o: ex_sum.c gcc -c ex_sum.c mysum.o: mysum.c mysum.h gcc -c mysum.c
-
shell脚本程序(整除) p86
-
例题:编写显示20以内能被3整除的数的shell脚本程序
#! /bin/bash for((i=1;i<20;i++)) do if(( i% 3 == 0 )) then echo $ i fi done
-
-
同时控制两个LED灯的点亮或熄灭的程序 p93-94
volatile unsigned int *GPC0CON=(volatile unsigned int *) 0xE0200060; volatile unsigned int *GPC0DAT=(volatile unsigned int *) 0xE0200064; void delay() { int k=0x100000; while (k--); } int main(void) { int i=0; *GPC0CON &= ~0xff000; *GPC0CON |=0x11000; while (1) { *GPC0DAT &= ~(3<<3); *GPC0DAT |=i<<3; i++; if(i==4){i=0;} delay(); } return 0; }
-
文件的创建和读写程序 p121 例6-2 6-3
#include<fcntl.h>
#include<string.h>
#include<stdio.h>
Int mian()
{
Int fd;
fd=open("b.txt",O_CREAT|O_TRUNC|O_RDWR,0666);
printf(("create_file:b.txtfd=%d\n",fd);
char *buf="this is a embedded course!";
int len=strien(buf);
int size=write(fd,buf,len);
lseek(fd,0,SEEK_SET);
char buf1[50];
int size1=read(fd,buf1,50);
printf("size1=%d,b.txt context are:%s\n",size1,buf1);
close(fd);
return0;
}
- 管道程序、父进程向管道写入字符串、子进程从管道中读取字符串 p131改题
#include<stdio.h>
#include<stdlib.h>
int main()
{
int x,fd[2];
char buf[50],s[50];
pipe(fd);
x=fork();
if(x==0)
{
close(fd[1]);
sleep(1);
read(fd[0],s,sizeof(s));
printf(“read string:%s\n”,s);
close(fd[0]);
exit(0);
}
else if(x>0)
{
close(fd[0]);
sprintf (buf,”this is an another pipe!”);
write(fd[1],buf,sizeof(buf));
close(fd[1]);
wait(x,NULL,0);
exit(0);
}
}
- 建立从共享内存中读取数据的进程程序 p134 例6-13
#include<stdio.h>
#include<sys/shm.h>
int main(int argc,char * argv[])
{
int shm_id;
char * shm_buf,str[50];
shm_id = atoi(argv[1]);
shm_buf = shmat(shm_id,0,0)
printf("读取共享内存数据:\n");
sprintf(str,shm_buf);
printf("%s \n",str);
system("ipcs -m");
}
- 解除进程到共享内存的映射,并释放内存空间的程序 p135 例6-14
#include<stdio.h>
#include<sys/shm.h>
int main(int argc,char * argv[])
{
int shm_id;
char * shm_buf;
shm_id = atoi(argv[1]);
shm_buf = shmat(shm_id,0,0)
shmdt(shm_buf);
shmctl(shm_id,IPC_RMID,NULL);
system("ipcs -m");
}