Presentation is loading. Please wait.

Presentation is loading. Please wait.

chapter 1-Introduction

Similar presentations


Presentation on theme: "chapter 1-Introduction"— Presentation transcript:

1 chapter 1-Introduction
中国科学技术大学软件学院

2 课程内容介绍 课程 相应实验 第一部分:linux嵌入式开发基础 linux的基本命令实验 VI编辑器实验 模块的编写实验
第二部分:驱动基础-字符设备驱动 简单字符设备驱动的编写 scull驱动程序的理解 第三部分:字符设备驱动核心理论(并发、中断、定时器、阻塞、I/O操作、内存分配等) 驱动程序中并发实验 驱动程序中中断实验 驱动程序中定时器实验 驱动设计中阻塞实验 第四部分:块设备、网络设备驱动 块设备驱动程序实验 驱动示例 A/D驱动程序解析 触摸屏驱动程序解析 USB摄像头驱动分析

3 initialize() while(true) { if (condition_1) action_1(); if (condition_2) action_2(); ...... if (condition_n) acition_n(); } Check for Input Do Something

4 ? #include <sys/types>
#include <sys/stat.h> /*库文件在/usr/include/下*/ #include <fcntl.h> #include <stdio.h> #define LENGTH 100 main() { int fd,len; fd =open("hello.txt",O_CREAT | 0_RDWR,S_IRUSR |S_IWDSR); char str[LENGTH]; if (fd) write(fd,"hello world",strlen("hello world"));/*写入*/ close (fd); } fd =open("hello.txt",O_RDWR);/*打开文件*/ len=read(fd,str,LENGTH);/*读取文件内容*/ str[len]='\0'; printf ("%s\n",str); close(fd); ?

5 1 2 3 4 5 Process Management Memory Management Virtual File systems
Network management 4 Inter-Process Communication 5

6

7 #include <syscall.h>
#include <unistd.h> #include <stdio.h> #include <sys/types.h> int main(void) { long ID1, ID2; /* */ /* SYS_getpid (func no. is 20) */ ID1 = syscall(SYS_getpid); printf ("syscall(SYS_getpid)=%ld\n", ID1); /* SYS_getpid (Func No. is 20) */ ID2 = getpid(); printf ("getpid()=%ld\n", ID2); return(0); }

8 Inter-Process Communication
Sender: struct msg{ long msg_types; char msg_buf[511]; }; int main( void ) { int qid; int pid; int len; struct msg pmsg; pmsg.msg_types = getpid(); sprintf (pmsg.msg_buf,"hello!this is :%d\n\0", getpid() ); len = strlen ( pmsg.msg_buf ); if ( (qid=msgget(IPC_PRIVATE, IPC_CREAT | 0666)) < 0 ) { perror ( "msgget" ); exit (1) ; } if ( (msgsnd(qid, &pmsg, len, 0 )) < 0 ){ perror ( "msgsn" ); exit ( 1 ); printf ("successfully send a message to the queue: %d \n", qid); exit ( 0 ) ;

9 Inter-Process Communication
Accepter: struct msg{ long msg_types; char msg_buf[511]; }; int main( int argc, char * argv[] ) { int qid; int len; struct msg pmsg; if ( argc != 2 ){ /**/ perror ( "USAGE: read_msg <queue ID>" ); exit ( 1 ); } qid = atoi ( argv[1] ); len = msgrcv ( qid, &pmsg, BUFSZ, 0, 0 ); if ( len > 0 ){ pmsg.msg_buf[len] = '\0'; printf ("reading queue id :%05ld\n", qid );

10 linux operation

11 linux operation

12 linux operation-soft link

13 linux operation

14 thank you !


Download ppt "chapter 1-Introduction"

Similar presentations


Ads by Google