Microsoft PowerPoint - LN_8_Linux_INT_Module.ppt [호환 모드]

Size: px
Start display at page:

Download "Microsoft PowerPoint - LN_8_Linux_INT_Module.ppt [호환 모드]"

Transcription

1 프로젝트 1 Interrupt, Module Programming 단국대학교컴퓨터학과 2009 백승재 ibanez1383@dankook.ac.kr k k

2 강의목표 Linux 의인터럽트처리과정이해 시스템호출원리파악 모듈프로그래밍기법숙지

3 인터럽트의분류 3 인터럽트 외부인터럽트 fault page fault, 트랩 trap int, system call, abort devide by zero,

4 인터럽트와트랩의처리 4 devide by zero error debug nmi int3 H/W 0 1 CPU 2 IDT(IVT) idt_table devide_error debug nmi Kernel sys_call_table 0 sys_restart_syscall syscall sys_exit sys_write timer 3 int3 N action irq_desc action keyboard 32 0 timer_interrupt PIC floppy do_irq floppy_interrupt HDD 128 system_call floppy_interrupt action action

5 irq_desc 5 irq_desc NR_IRQS( 보통 224) 개의 irq_desc_t 디스크립터의배열 status : IRQ 선의상태나타내는 flags handler : IRQ선을처리하는 PIC회로를나타내는 hw_interrupt_type 디스크립터에대한ptr action : IRQ가발생할때호출할 ISR lock : IRQ디스크립터에대한 spin lock

6 irqaction 6 irqaction 디스크립터 handler : I/O device 용 ISR 을가리킴 flags : IRQ 선과 I/O device 간의관계설명 name : I/O device 의이름 dev_id : I/O device 서사용하는 private 필드 next : irqaction 디스크립터리스트의다음항목을가리킴

7 인터럽트처리과정 7 do_irq() 스택에는 return addr, SAVE_ALL로저장한 reg값, 변환한 IRQ번호, INT발생시 CU가자동저장한 reg unsigned int do_irq(struct pt_regs regs) pt_regs 처음 9필드는 SAVE_ALL로저장한 reg값, 10번째는 orig_eax로참조하는필드 = 변환한 IRQ번호, 나머지는 CU가자동저장한 regls

8 시스템호출처리 8 User program C library Call gate 유저레벨커널레벨 System call handler System call rountine

9 시스템호출처리과정 9 시스템호출처리과정예 : fork user task main(). fork() libc.a 0x0 IDT divide_error() debug() nmi() Kernel ENTRY(system_call) /* arch/i386/kernel/entry.s */ SAVE_ALL. call *SYMBOL_NAME(sys_call_table)(,%eax,4). ret_from_sys_call (schedule, signal, bh_active, nested interrupt handling). sys_call_table. fork(). movl 2, %eax 1 sys_exit() int $0x80 0x80 system_call(). 2 sys_fork().. 3 sys_read () 4 sys_write (). sys_fork() /* arch/i386/kernel/process.c c */ /* kernel/fork.c */

10 시스템호출처리관련 10 system_call() sys_system_call() asmlinkage 함수의 argument 를 stack 을통해전달받음 Asm내에서 C 함수를호출할수있도록함 시스템콜번호 각시스템콜에시스템콜번호부여. 고유한숫자 sys_call_table에저장하고있다 시스템콜핸들러 int $0x80 128번 vector의, 프로그래밍에의한예외발생 순서 시스템콜사용위해커널에인터럽트를건다 (eax에 syscall번호 ) reg를커널모드스택에저장 시스템콜서비스루틴호출하여처리 ret_from_sys_call() 로핸들러서빠져나옴적법한매개변수, 퍼미션인지검사필수 copy_to_user(), copy_from_user() 사용

11 system_call 함수 넘어온매개변수를커널모드스택에저장 제어유닛이자동으로저장한 eflags, cs, eip, ss, esp 제외한모든 reg 를스택에저장 2. ebx reg 에 current P 의디스크립터를저장 3. current 의 ptrace 필드에 PT_TRACESYS 플래그가들어있는지, 즉디버거가프로그램의시스템콜호출을추적중인지검사 syscall_trace() 를처음, 마지막두번호출하게됨 4. 올바른 syscall 번호인지검사. 잘못된번호이면바로종료 5. dispatch table의각엔트리는 4바이트이므로, 시스템콜번호에 4를곱한후 + sys_call_table 시작주소를더해서 서비스루틴의 ptr얻어와서호출함. 호출종료되면리턴값을저장한스택 ( 사용자모드에서의 eax) 에저장해놓고,syscall 핸들러를종료하는 ret_from_sys_call로점프

12 복귀과정 12

13 매개변수와주소공간 13 매개변수확인 매개변수가주소인경우검사방법두가지선형주소가 P 주소공간에속하는지, 속하면접근권한이있는지검사선형주소가 PAGE_OFFSET보다낮은지만확인 access_ok() 이용 system call에전달한주소검사 프로세스주소공간접근

14 새로운시스템호출구현 (1/7) 14 새로운시스템호출구현 커널수정 : 4 단계 1. 새로운시스템호출번호할당 (allocate syscall_number) 2. 새로운시스템호출함수 sys_call_table[] 에등록 3. 새로운시스템호출함수커널에구현 4. 커널컴파일및리부팅 사용자응용작성 : 2단계 1. 새로운시스템호출을사용하는사용자수준응용작성 2. 라이브러리로사용자응용작성 (optional) : ar, ranlib

15 새로운시스템호출구현 (2/7) 새로운시스템호출구현예 : newsyscall() 이라는이름의새로운시스템호출구현 새로운시스템호출번호할당 /* include/x86/unistd_32.h 파일의내용 */ #define NR_restart_syscall 0 #define NR_exit 1 #define NR_fork 2 #define NR_read 3 #define NR_write 4 #define NR_open 5 #define NR_close 6 #define NR_epoll_create 254 #define NR_epoll_ctl 255 #define NR_epoll_wait 256 #define NR_fallocate 324 #define NR_newsyscall 325 #define NR_syscalls 326

16 새로운시스템호출구현 (3/7) 새로운시스템호출함수 sys_call_table[] 에등록 sys_call_table /* arch/x86/kernel/syscall_table_32.s ll 파일의내용 */ ENTRY(sys_call_table).long sys_restart_syscall syscall.long sys_exit.long sys_fork.long sys_read.long sys_write.long sys_open.long sys_close.long sys_epoll_create.long sys_epoll_ctl.long sys_epoll_wait.long sys_fallocate.long sys_newsyscall 0 sys_ni_syscall() syscall() sys_exit() sys_fork() sys_read() sys_write() 256 sys_epoll_wait() 324 sys_fallocate() 325 sys_newsyscall()

17 새로운시스템호출구현 (4/7) 새로운시스템호출함수커널에구현 /* kernel/newfile.c 파일의내용 */ #include <linux/unistd.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/sched.h> asmlinkage long sys_newsyscall(void) printk("<0>hello Linux, I'm in Kernel\n"); return 0; EXPORT_SYMBOL_GPL(sys_newsyscall); printf() 가아니라 printk() 임에주의

18 새로운시스템호출구현 (5/7) 커널컴파일및리부팅 커널컴파일전에 makefile 을다음과같이수정해야한다. /* kernel/makefile 의변경전내용 */ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o /* kernel/makefile 의변경후내용 */ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.oo workqueue.oo pid.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o newfile.o 커널컴파일후재부팅

19 새로운시스템호출구현 (6/7) 새로운시스템호출을사용하는사용자수준응용작성 /* /usr/include/asm-x86/unistd_32.h */ #define NR_signalfd 321 #define NR_timerfd 322 #define NR_eventd 323 #define NR_fallocate 324 #include <linux/unistd.h> int main(void) syscall(325); return 0; /* /usr/include/asm-x86/unistd_32.h */ #define NR_signalfd 321 #define NR_timerfd 322 #define NR_eventd 323 #define NR_fallocate 324 #define NR_newsyscall 325 #include <linux/unistd.h> int main(void) syscall( NR_newsyscall); return 0;

20 syscall 매크로 20 /* /usr/include/unistd.h */ extern long int syscall (long int sysno,...) THROW; /* glibc/sysdeps/unix/sysv/linux/i386/syscall.s */.text ENTRY (syscall) PUSHARGS_6 /* Save register contents. */ _DOARGS_6(44) /* Load arguments. */ movl 20(%esp), %eax /* Load syscall number into %eax. */ ENTER_KERNEL /* Do the system call. */ POPARGS_6 /* Restore register contents. */ cmpl $-4095, %eax /* Check %eax for error. */ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ L(pseudo_end): ret /* Return to caller. */ PSEUDO_END END (syscall) /* glibc/sysdeps/unix/sysv/linux/i386/sysdep.h */ # define ENTER_KERNEL int $0x80

21 새로운시스템호출구현 (7/7) 라이브러리로사용자응용작성 $ vi newsys.c $ gcc c newsys.c $ ar -r libnew.a newsys.o $ vi test.c $ gcc O o test test.c L./ -lnew $./test #include <linux/unistd.h> int newsyscall(void) syscall( NR_newsyscall); #include <linux/unistd.h> int main(void) newsyscall(); return 0;

22 시스템호출구현확장 (1/7) 22 인자전달 기존시스템호출분석 커널정보얻기 모듈프로그래밍을이용한시스템호출구현 => 모듈프로그래밍장참조 Just Do It ( 百見不如一打 )

23 시스템호출구현확장 (2/7) 23 인자전달 : show_mult(arg1, arg2, result) 1. 새로운시스템호출번호할당 : 192번 2. 새로운시스템호출함수 sys_call_table[] 에등록 3. 새로운시스템호출함수커널에구현 #include<linux/unistd.h> #include<linux/kernel.h> #include<asm-x86/uaccess.h> asmlinkage int sys_show_mult(int x, int y, int* res) int error, compute; int i; error = access_ok(verify_write,res,sizeof(*res)); if(error < 0) printk("error in cdang\n"); printk("error is %d\n",error); return error; compute = x*y; printk("computeis %d\n",compute); i= copy_to_user(res,&compute,sizeof(int)); return 0; 4. 커널컴파일및리부팅

24 시스템호출구현확장 (3/7) 24 인자전달 : show_mult(arg1, arg2, result) 1. 사용자수준응용 #include <stdio.h> #include <linux/unistd.h> int main(void) int mult_ret = 0; int x = 2,y=5; int i; i=syscall(325,x,y,&mult_ret); printf("x is %d\ny is %d\nret is %d\n",x,y,mult_ret); return 0;

25 시스템호출구현확장 (4/7) 25 커널정보얻기 : gettaskinfo() header //mystat.h #include<linux/kernel.h> #include<linux/sched.h> struct mystat pid_t pid; pid_t ppid; int stat; int priority; int policy; long utime; long stime; long starttime; unsigned long min_flt; unsigned long maj_flt; long open_files; ;

26 시스템호출구현확장 (5/7) 26 커널정보얻기 : gettaskinfo() 커널함수 asmlinkage int sys _g gettaskinfo(int id, struct mystat *user_ buf) struct mystat *buf; int i, cnt = 0; struct task_struct *search; struct file *fp; search = &init_task; while(search->pid!= id) // search = next_task(search); // 아래 list_entry 대신사용가능 search = list_entry((search)->tasks.next,struct task_struct,tasks); if(search->pid == init_task.pid) printk("init_task\n"); return -1; buf = (char*)kmalloc(sizeof(struct mystat),gfp_kernel); if(buf == NULL) printk("buf is NULL\n"); return -1; buf->pid = search->pid; buf->ppid = search->parent->pid; buf->stat = search->state; buf->priority = search->prio; buf->policy = search ->policy; buf->utime = search->utime; buf->stime = search->stime; buf->starttime = search->start_time.tv_sec; buf->min_flt flt = search->min_flt; buf->maj_flt = search->maj_flt; for(i = 0; i<32; i++) if( (search->files->fd_array[i])!=null) cnt++; buf->open_files = cnt; copy_to_user(user_buf,buf,sizeof(struct mystat)); return 0;

27 시스템호출구현확장 (6/7) 27 커널정보얻기 : gettaskinfo() 사용자수준응용 #include"mystat.h" #include<linux/unistd.h> int main(int argc, char* argv[]) int task_number; struct mystat* mybuf; if(argc!=2) printf("usage : a.out pid \n"); exit(1); task_number = atoi(argv[1]); mybuf = (char*)malloc(sizeof(struct mystat)); if(mybuf == NULL) exit(1); syscall(326,task_number,mybuf); printf("pid is %d\n",(int)mybuf->pid); printf("ppid ppid is %d\n",(int)mybuf->ppid); printf("state is %d\n",(int)mybuf->stat); printf("policy is %d\n",(int)mybuf->policy); printf("file count is %d\n",mybuf->open_files); printf("start time is %d\n",mybuf->starttime); return 0;

28 시스템호출구현확장 (7/7) 28 기존시스템호출분석 fork - p = alloc_task_struct() - task structure initialize - copy_mm(). - copy_thread() -wake_up_process(p) -return(p->pid) p /* arch/i386/kernel/process.c c */ sys_fork() /* kernel/fork.c */ do_fork() /* arch/i386/kernel/entry.s */ ret_from_sys_call() /* arch/i386/kernel/process.c */ copy_thread(). - p->tss.eax = 0; - p->tss.eip = ret_from_fork; /* kernel/sched.c */ wake_up_process() - add_to_runqueue(p); - current->need >need_resched = 1 /* kernel/sched.c */ schedule() if (schedule parent) else (schedule child)

29 모듈프로그래밍의동기 29 Linux 에서모듈프로그래밍이개발된이유 Linux 는모노리딕커널 (monolithic kernel) 모든기능이커널내부에구현되어있다. 사소한커널변경 (trivial modification) 에도커널컴파일과리부팅이필요 커널의크기가너무크다. 커널의일부기능은거의사용되지않지만, 메모리에상주하고있다. 모듈프로그래밍 module: steps toward micro-kernelized Linux 커널의일부기능을커널에서빼고모듈로구현 그기능이필요할때만메모리에적재 작고깔끔한커널가능 (small and clean kernel) 메모리의효율적이용 커널기능의수정때마다컴파일및리부팅의필요가없다.

30 모듈프로그래밍의범위 30 모듈프로그래밍의범위 하드웨어종속적인부분과초기화부분을제외한거의모든커널기능을모듈로만들수있다. 주로파일시스템과디바이스드라이버 현재 Linux 가지원하는모듈인터페이스 file system register_filesystem, unregister_filesystem read_super, put_super block device driver register_blkdev, unregister_blkdev open, release character device driver register_chrdev, unregister_chrdev open, release network device driver register_netdev, unregister_netdev open, close exec domain register_exec_domain, i unregister_exec_domain load_binary, personality binary format register_binfmt, unregister_binfmt load_binary.

31 모듈의관리 31 모듈의메모리적재 insmod, lsmod, rmmod, modprobe #insmod fat.o #lsmod Module: #pages : Used by fat 6 0 #rmmod fat kerneld (kmod) : 자동모듈적재데몬 eg: mount -t msdos /dev/fd0 /mnt => transparent load fat & msdos modules

32 모듈프로그래밍예 (1/3) 커널을위한 hello_module #include <linux/kernel.h> #include <linux/module.h> int hello_module_init(void) _ printk(kern_emerg "Hello Module~! I'm in Kernel n"); return 0; void hello_module_cleanup(void) printk("<0>bye Module~! n"); module_init(hello_module_init); init); module_exit(hello_module_cleanup); MODULE_LICENSE("GPL");

33 모듈프로그래밍예 (2/3) 커널에서모듈컴파일을위한 Makefile O_TARGET := hello_module.ko obj-m := hello_module.o KERNEL_DIR := /lib/modules/$(shell uname -r)/build MODULE_DIR := /lib/modules/$(shell uname -r)/kernel/hello_module PWD := $(shell pwd) default : $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules install : mkdir -p $(MODULE_DIR) cp -f $(O_TARGET) $(MODULE_DIR) clean : $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) clean

34 모듈프로그래밍예 (3/3) 커널에서모듈테스트를위한명령어수행 $ vi Makefile $ vi hello_module.c $ ls Makefile hello_module.c $make $ ls Makefile hello_module.c hello_module.ko $ insmod hello_module.ko Hello Module~! I m in Kernel $ rmmod hello_module Bye Module~! $makeinstall $ ls l /lib/modules/2.6.18/kernel/hello_module hello_module.ko $ make clean $ ls Makefile hello_module.c

35 모듈프로그램 : system call wrapper (1/3) 커널에서모듈을통한 system call wrapper 35 #include <linux/kernel.h> #include <linux/module.h> #include <linux/syscalls.h> /y #include <linux/slab.h> #include <linux/sched.h> #include <linux/fs.h> #include <asm/uaccess.h> #include <asm-i386/unistd.h> #include <asm-i386/pgtable.h> unsigned long **sys_call_table; unsigned long **locate_sys_call_table(void) unsigned long temp; unsigned *p; unsigned long **sys_table; for ( temp = 0xc ; temp < 0xd ; temp+= sizeof(void *)) p = (unsigned long *)temp; if( p[ NR_close] == (unsigned long)sys_close) l ) sys_table = (unsigned long **)p; return &sys_table[0]; return NULL; asmlinkage int (*original_call)(const char *, int, int); asmlinkage int sys_our_open(const char *filename, int flags, int mode) printk("<0>open system call n"); return (original_call(filename, flags, mode));

36 모듈프로그램 : system call wrapper (2/3) #define flush_tlb_single(addr) single(addr) asm volatile ("invlpg (%0)" ::"r" (addr) : "memory") int syscall_hooking_init(void) if( (sys_call_table = locate_sys_call_table()) == NULL) printk("<0> Can't find sys_call_table n"); return -1; pgd_t *pgd = pgd_offset_k((unsigned long)sys_call_table); pud _ t *pud; pmd _ t *pmd; pte _ t *pte; if( pgd_none(*pgd)) return NULL; pud = pud_offset(pgd, (unsigned long)sys_call_table); if( pud_none(*pud)) return NULL; pmd = pmd_offset(pud, (unsigned long)sys_call_table); if( pmd_none(*pmd)) return NULL; if( pmd_large(*pmd)) pte = (pte_t *)pmd; else pte = pte_offset_kernel(pmd, (unsigned long)sys_call_table); pte->pte_low = _PAGE_KERNEL; flush_tlb_single((unsigned long)sys_call_table); printk("<0> sys_call_table is loaded at %p n", sys_call_table); original_call = (void *)sys_call_table[ NR_open]; sys_call_table[ NR_open] = (void *)sys_our_open; printk("<0> Module Init n"); return 0;

37 모듈프로그램 : system call wrapper (3/3) void syscall_hooking_cleanup(void) cleanup(void) sys_call_table[ NR_open] = original_call; printk("<0> Module cleanup n"); module_init(syscall_hooking_init); module_exit(syscall_hooking_cleanup); MODULE_LICENSE("GPL");

Microsoft PowerPoint - Chapter_05.pptx

Microsoft PowerPoint - Chapter_05.pptx 1 Interrupt, Trap and System call May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 인터럽트의분류 2 인터럽트 외부인터럽트 fault page fault, 트랩 trap int, system call, abort devide by

More information

06Àå

06Àå Chapter 5 Chapter 6 Chapter 7 chapter 6 Part 1 6.1 Part 2 Part 3 145 146 Chapter 5 Chapter 6 Chapter 7 Part 1 Part 2 Part 3 147 148 Chapter 5 Chapter 6 Chapter 7 Part 1 Part 2 Part 3 149 150 Chapter 5

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 8: System Call ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 시스템콜인터페이스이해하기 커널에시스템콜추가하는방법알아보기 커널에시스템콜추가하기 추가한시스템콜검증하기 인자를갖는시스템콜작성하기 2 시스템콜인터페이스 일반적으로사용자모드의프로세스 (user mode

More information

<4D F736F F F696E74202D20B8AEB4AABDBAC4BFB3CEC7C1B7CEB1D7B7A1B9D62D352E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBAC4BFB3CEC7C1B7CEB1D7B7A1B9D62D352E BC8A3C8AF20B8F0B5E55D> 리눅스커널프로그래밍 Ki-Hyun JUNG kingjung@paran.com 참고 : Linux Kernel Programming Kernel Module Programming 커널프로그래밍 Add-on Linux Kernel 1 운영체제가관리 자원관리 물리적인자원 (Physical Resource) CPU, 메모리, 디스크, 터미널, 네트워크등 시스템을구성하고있는요소들과주변장치

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 시스템호출개요 리눅스에서는사용자공간과커널공간을구분 사용자프로그램은사용자모드, 운영체제는커널모드에서수행 커널공간에대한접근은커널 ( 특권, priviledged) 모드에서가능 컴퓨팅자원 (CPU, memory, I/O 등 ) 을안전하게보호 커널수행을안전하게유지

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 16: ioctl 을활용한 LED 제어디바이스드라이버 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 ioctl() 을활용법배우기 커널타이머와 ioctl 을활용하여 LED 제어용디바이스드라이브작성하기 2 IOCTL 을이용한드라이버제어 ioctl() 함수활용 어떤경우에는읽는용도로만쓰고,

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

Microsoft PowerPoint - 10-EmbedSW-11-모듈

Microsoft PowerPoint - 10-EmbedSW-11-모듈 11. 개요 proc 파일시스템 순천향대학교컴퓨터학부이상정 1 개요 순천향대학교컴퓨터학부이상정 2 개요 커널프래그래밍 커널의일부변경시커널전체를다시컴파일해야하는번거로움 해당모듈만컴파일하고필요할때만동적으로링크시켜커널의일부로사용할수있어효율적 자주사용하지않는커널기능은메모리에상주시키지않아도됨 확장성과재사용성을높일수있음. 순천향대학교컴퓨터학부이상정 3 모듈 (module)

More information

Microsoft PowerPoint - e9.pptx

Microsoft PowerPoint - e9.pptx Kernel Programming 이란? 커널모드에서수행하는프로그램을작성하는것 임베디드리눅스커널프로그래밍 커널프로그래밍종류 Linux kernel core 기능추가 Linux kernel 알고리즘개선 Linux kernel 모듈프로그래밍 커널컴파일필요없음 2 Kernel Program vs. Application Program (1) Kernel Program

More information

KEY 디바이스 드라이버

KEY 디바이스 드라이버 KEY 디바이스드라이버 임베디드시스템소프트웨어 I (http://et.smu.ac.kr et.smu.ac.kr) 차례 GPIO 및 Control Registers KEY 하드웨어구성 KEY Driver 프로그램 key-driver.c 시험응용프로그램 key-app.c KEY 디바이스드라이버 11-2 GPIO(General-Purpose Purpose I/O)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

Microsoft PowerPoint - lab14.pptx

Microsoft PowerPoint - lab14.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. Keypad Device Control in Embedded Linux HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착되어있다. 2 Keypad Device Driver

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

10.

10. 10. 10.1 10.2 Library Routine: void perror (char* str) perror( ) str Error 0 10.3 10.3 int fd; /* */ fd = open (filename, ) /*, */ if (fd = = -1) { /* */ } fcnt1 (fd, ); /* */ read (fd, ); /* */ write

More information

<4D F736F F F696E74202D205BBAB0C3B75D20B8AEB4AABDBA20B5F0B9D9C0CCBDBA20B5E5B6F3C0CCB9F620B8F0B5A82E >

<4D F736F F F696E74202D205BBAB0C3B75D20B8AEB4AABDBA20B5F0B9D9C0CCBDBA20B5E5B6F3C0CCB9F620B8F0B5A82E > 안드로이드환경에서의 리눅스디바이스드라이버 문자디바이스드라이버설명 Table of contents 디바이스드라이버구조 시스템구조 모듈의기본골격 드라이버 IO 제어 안드로이드환경에서의 한백전자교육사업부 리눅스디바이스드라이버 시스템구조 쉘 응용프로그램 표준라이브러리 시스템콜 가상파일시스템 (VFS) 버퍼캐시 네트워크시스템 문자디바이스드라이버 블럭디바이스드라이버 네트워크디바이스드라이버

More information

리눅스커널-06

리눅스커널-06 C h a p t e r 06 CPU CPU CPU 1MB 600KB 500KB 4GB 512MB 1GB 230 231 Virtual Memory Physical Memory Virtual address Physical address 0 CPU 4GB 3GB 1GB 61 init proc1maps cat 0x08048000 0xC0000000 0x08048000

More information

ABC 11장

ABC 11장 12 장고급응용 0 수행중인프로그램 프로세스 모든프로세스는유일한프로세스식별번호 (PID) 를가짐 유닉스에서는 ps 명령을사용하여프로세스목록을볼수있음 12-1 프로세스 $ ps -aux USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND blufox 17725 34.0 1.6 146 105 i2 R 15:13 0:00

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

/chroot/lib/ /chroot/etc/

/chroot/lib/ /chroot/etc/ 구축 환경 VirtualBox - Fedora 15 (kernel : 2.6.40.4-5.fc15.i686.PAE) 작동 원리 chroot유저 ssh 접속 -> 접속유저의 홈디렉토리 밑.ssh의 rc 파일 실행 -> daemonstart실행 -> daemon 작동 -> 접속 유저만의 Jail 디렉토리 생성 -> 접속 유저의.bashrc 의 chroot 명령어

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

Microsoft Word doc

Microsoft Word doc 1. 디바이스드라이버 [ GPIO ] 1.1. GPIO 란 GPIO(General Purpose Input/Output) 란일반적인용도로사용가능한디지털입출력기능의 Port pins 이다. S3C2410의 GPIO는총 117개이며각각이 pin 들은 input/output으로프로그램되거나인터럽트 source로사용될수있다. S3C2410의대부분의 GPIO는단순히디지털입출력뿐만아니라부가적인기능을갖고있다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - (Asynchronous Mode) - - - ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 - UART (Univ ers al As y nchronous Receiver / T rans mitter) 8250A 8250A { COM1(3F8H). - Line Control Register

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED Controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

망고100 보드로 놀아보자 -13

망고100 보드로 놀아보자 -13 리눅스디바이스드라이버개요 http://cafe.naver.com/embeddedcrazyboys http://www.mangoboard.com 디바이스드라이버개요 디바이스 (Device ) 네트워크어댑터, LCD 디스플레이, PCMCIA, Audio, 터미널, 키보드, 하드디스 크, 플로피디스크, 프린터등과같은주변장치들을말함 디바이스의구동에필요한프로그램, 즉디바이스드라이버가필수적으로요구

More information

슬라이드 1

슬라이드 1 / 임베디드시스템개요 / 임베디드운영체제 / 디바이스드라이버 01 Linux System Architecture Application Area Application System Call Interface BSD Socket Virtual File System INET(AF_INET) Kernel Area Buffer Cache Network Subsystem

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

More information

Deok9_Exploit Technique

Deok9_Exploit Technique Exploit Technique CodeEngn Co-Administrator!!! and Team Sur3x5F Member Nick : Deok9 E-mail : DDeok9@gmail.com HomePage : http://deok9.sur3x5f.org Twitter :@DDeok9 > 1. Shell Code 2. Security

More information

좀비프로세스 2

좀비프로세스 2 Signal & Inter-Process Communication Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 좀비프로세스 2 좀비프로세스 (zombie process) 좀비프로세스란프로세스종료후메모리상에서사라지지않는프로세스 좀비프로세스의생성이유. 자식프로세스는부모프로세스에게실행결과에대한값을반환해야한다.

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

ECE30076 Embedded System Programming - LED Device Driver

ECE30076 Embedded System Programming - LED Device Driver Module 12: LED 제어디바이스드라이버 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 하드웨어제어를위한디바이스드라이버작성방법알아보기 LED 제어용디바이스드라이버작성하기 ioremap 을이용한 LED 제어디바이스드라이버 mmap 을이용한 LED 제어디바이스드라이버 2 디바이스구분

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-SEGMENT DEVICE CONTROL - DEVICE DRIVER Jo, Heeseung 디바이스드라이버구현 : 7-SEGMENT HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 디바이스드라이버구현 : 7-SEGMENT 6-Digit 7-Segment LED

More information

Microsoft Word - Network Programming_NewVersion_01_.docx

Microsoft Word - Network Programming_NewVersion_01_.docx 10. Unix Domain Socket 105/113 10. Unix Domain Socket 본절에서는 Unix Domain Socket(UDS) 에대한개념과이에대한실습을수행하고, 이와동시에비신뢰적인통신시스템의문제점에대해서분석하도록한다. 이번실습의목표는다음과같다. 1. Unix Domain Socket의사용법을익히고, IPC에대해서실습 2. TCP/IP의응용계층과전달계층의동작을구현및실습

More information

1217 WebTrafMon II

1217 WebTrafMon II (1/28) (2/28) (10 Mbps ) Video, Audio. (3/28) 10 ~ 15 ( : telnet, ftp ),, (4/28) UDP/TCP (5/28) centralized environment packet header information analysis network traffic data, capture presentation network

More information

untitled

untitled Embedded System Lab. II Embedded System Lab. II 2 RTOS Hard Real-Time vs Soft Real-Time RTOS Real-Time, Real-Time RTOS General purpose system OS H/W RTOS H/W task Hard Real-Time Real-Time System, Hard

More information

슬라이드 1

슬라이드 1 프로세스 (Process) (1) Chapter #5 Process 정의 Process 구조 Process Context Process Scheduling 강의목차 Unix System Programming 2 Program( 프로그램 ) Process 정의 (1) 기계어명령어와데이터를모아놓은실행파일 C 언어등프로그램언어로작성된소스파일을컴파일링하여생성 COFF(Common

More information

Abstract View of System Components

Abstract View of System Components Operating System 4 주차 - System Call Implementation - Real-Time Computing and Communications Lab. Hanyang University jtlim@rtcc.hanyang.ac.kr yschoi@rtcc.hanyang.ac.kr shpark@rtcc.hanyang.ac.kr Contents

More information

Embeddedsystem(8).PDF

Embeddedsystem(8).PDF insmod init_module() register_blkdev() blk_init_queue() blk_dev[] request() default queue blkdevs[] block_device_ops rmmod cleanup_module() unregister_blkdev() blk_cleanup_queue() static struct { const

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Linux Kernel and Device Driver Jo, Heeseung 커널과의관계 시스템이지원하는하드웨어를응용프로그램에서사용할수있도록커널에서제공하는라이브러리 응용프로그램이하드웨어를제어하려면커널에자원을요청 - 응용프로그램에서는 C 라이브러리같은함수를호출 - 라이브러리내부에서는커널에게시스템콜을호출 - 커널로제어가넘어가게되면 ( 커널모드 ) 를통해서하드웨어를제어

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F > 10주차 문자 LCD 의인터페이스회로및구동함수 Next-Generation Networks Lab. 5. 16x2 CLCD 모듈 (HY-1602H-803) 그림 11-18 19 핀설명표 11-11 번호 분류 핀이름 레벨 (V) 기능 1 V SS or GND 0 GND 전원 2 V Power DD or V CC +5 CLCD 구동전원 3 V 0 - CLCD 명암조절

More information

System Programming Lab

System Programming Lab System Programming Lab Week 4: Shell Schedule for your own shell 1 st shell 기본기능 fork / exec Background Processing/ Sequential Execution ls, find, grep 2 nd Environment variables/ Shell variables built-in

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 (Host) set up : Linux Backend RS-232, Ethernet, parallel(jtag) Host terminal Target terminal : monitor (Minicom) JTAG Cross compiler Boot loader Pentium Redhat 9.0 Serial port Serial cross cable Ethernet

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D> 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 프로세스생성 [1] 프로그램실행

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 3/24 프로세스생성 [1]

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

Microsoft PowerPoint - chap6 [호환 모드]

Microsoft PowerPoint - chap6 [호환 모드] 제 6 장프로세스 (Process) 숙대창병모 1 내용 프로세스시작 / 종료 명령중인수 / 환경변수 메모리배치 / 할당 비지역점프 숙대창병모 2 프로세스시작 / 종료 숙대창병모 3 Process Start Kernel exec system call user process Cstart-up routine call return int main(int argc,

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 11: 가상디바이스드라이버작성 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 디바이스드라이버의실행과정이해하기 크로스컴파일러를이용하여가상의디바이스드라이버생성하기 Kbuild 에대해이해하기 2 file_operations 구조체 struct file_operations {

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서

디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서 임베디드시스템설계강의자료 7 Device Driver (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서디바이스를제어하기위한자료구조와함수의집합

More information

제9장 프로세스 제어

제9장 프로세스 제어 제 9 장프로세스제어 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 제 9 장 목차 프로세스생성 프로그램실행 입출력재지정 프로세스그룹 시스템부팅 2 9.1 절 프로세스생성 fork() 시스템호출 새로운프로그램을실행하기위해서는먼저새로운프로세스를생성해야하는데, fork() 시스템호출이새로운프로세스를생성하는유일한방법임. 함수프로토타입 pid_t fork(void);

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Sensor Device Jo, Heeseung Sensor 실습 HBE-SM5-S4210 에는근접 / 가속도 / 컴파스센서가장착 각센서들을사용하기위한디바이스드라이버와어플리케이션을작성 2 근접 (Proximity) 센서 HBE-SM5-S4210 Camera Module 근접센서디바이스 근접센서는사물이다른사물에접촉되기이전에가까이접근하였는지를검출할목적으로사용 일반적으로생활에서자동문이나엘리베이터,

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

Microsoft Word - ExecutionStack

Microsoft Word - ExecutionStack Lecture 15: LM code from high level language /* Simple Program */ external int get_int(); external void put_int(); int sum; clear_sum() { sum=0; int step=2; main() { register int i; static int count; clear_sum();

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

hlogin2

hlogin2 0x02. Stack Corruption off-limit Kernel Stack libc Heap BSS Data Code off-limit Kernel Kernel : OS Stack libc Heap BSS Data Code Stack : libc : Heap : BSS, Data : bss Code : off-limit Kernel Kernel : OS

More information

Microsoft Word - FunctionCall

Microsoft Word - FunctionCall Function all Mechanism /* Simple Program */ #define get_int() IN KEYOARD #define put_int(val) LD A val \ OUT MONITOR int add_two(int a, int b) { int tmp; tmp = a+b; return tmp; } local auto variable stack

More information

untitled

untitled if( ) ; if( sales > 2000 ) bonus = 200; if( score >= 60 ) printf(".\n"); if( height >= 130 && age >= 10 ) printf(".\n"); if ( temperature < 0 ) printf(".\n"); // printf(" %.\n \n", temperature); // if(

More information

1장. 유닉스 시스템 프로그래밍 개요

1장.  유닉스 시스템 프로그래밍 개요 Unix 프로그래밍및실습 7 장. 시그널 - 과제보충 응용과제 1 부모프로세스는반복해서메뉴를출력하고사용자로부터주문을받아자식프로세스에게주문내용을알린다. (SIGUSR1) ( 일단주문을받으면음식이완료되기전까지 SIGUSR1 을제외한다른시그널은모두무시 ) timer 자식프로세스는주문을받으면조리를시작한다. ( 일단조리를시작하면음식이완성되기전까지 SIGALARM 을제외한다른시그널은모두무시

More information

SRC PLUS 제어기 MANUAL

SRC PLUS 제어기 MANUAL ,,,, DE FIN E I N T R E A L L O C E N D SU B E N D S U B M O TIO

More information

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 종합과제 과제내용 구조체를이용하여교과목이름과코드를파일로부터입력받아관리 구조체를이용하여학생들의이름, 학번과이수한교과목의코드와점수를파일로부터입력 학생개인별총점, 평균계산 교과목별이수학생수, 총점및평균을계산 결과를파일에저장하는프로그램을작성 2 Makefile OBJS = score_main.o score_input.o score_calc.o score_print.o

More information

- 코드로읽는리눅스디바이스드라이버 강남용

- 코드로읽는리눅스디바이스드라이버 강남용 - 코드로읽는리눅스디바이스드라이버 - 2011.1.3 강남용 (nykang@ssu.ac.kr) 커널스레드 스레드란? 스레드종류 도우미인터페이스 연결리스트 해시리스트 작업큐 통지연쇄 완료인터페이스 kthread 도우미 오류처리지원 ( 원시코드살펴보기 ) 2 스레드란? - 하나의프로그램내에서실행되는함수를의미 - 일반적인프로세서의경우는한순간에하나의함수만실행되지만,

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 4 장파일 컴퓨터과학과박환수 1 2 4.1 시스템호출 컴퓨터시스템구조 유닉스커널 (kernel) 하드웨어를운영관리하여다음과같은서비스를제공 파일관리 (File management) 프로세스관리 (Process management) 메모리관리 (Memory management) 통신관리 (Communication management) 주변장치관리 (Device

More information

No Slide Title

No Slide Title Copyright, 2017 Multimedia Lab., UOS 시스템프로그래밍 (Assembly Code and Calling Convention) Seong Jong Choi chois@uos.ac.kr Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul Seoul, Korea

More information

Microsoft PowerPoint - polling.pptx

Microsoft PowerPoint - polling.pptx 지현석 (binish@home.cnu.ac.kr) http://binish.or.kr Index 이슈화된키보드해킹 최근키보드해킹이슈의배경지식 Interrupt VS polling What is polling? Polling pseudo code Polling 을이용한키로거분석 방어기법연구 이슈화된키보드해킹 키보드해킹은연일상한가! 주식, 펀드투자의시기?! 최근키보드해킹이슈의배경지식

More information

Microsoft PowerPoint - 09-Pipe

Microsoft PowerPoint - 09-Pipe 9. 파이프 상명대학교소프트웨어학부 파이프 시그널은이상한사건이나오류를처리하는데는이용하지만, 한프로세스로부터다른프로세스로대량의정보를전송하는데는부적합하다. 파이프 한프로세스를다른관련된프로세스에연결시켜주는단방향의통신채널 2 pipe() Usage #include int pipe(int filedes[2]); 3 < ex_1.c > #include

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 DEVELOPMENT ENVIRONMENT 2 MAKE Jo, Heeseung MAKE Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one 2

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Development Environment 2 Jo, Heeseung make make Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one It

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

More information

untitled

untitled Block Device Driver in Linux Embedded System Lab. II Embedded System Lab. II 2 Define objective of applications using device Study Hardware manual (Registers) (vector number) Understand interface to related

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 소켓프로그래밍활용 IT CookBook, 유닉스시스템프로그래밍 학습목표 소켓인터페이스를활용한다양한프로그램을작성할수있다. 2/23 목차 TCP 기반프로그래밍 반복서버 동시동작서버 동시동작서버-exec함수사용하기 동시동작서버-명령행인자로소켓기술자전달하기 UDP 프로그래밍 3/23 TCP 기반프로그래밍 반복서버 데몬프로세스가직접모든클라이언트의요청을차례로처리 동시동작서버

More information

vi 사용법

vi 사용법 유닉스프로그래밍및실습 gdb 사용법 fprintf 이용 단순디버깅 확인하고자하는코드부분에 fprintf(stderr, ) 를이용하여그지점까지도달했는지여부와관심있는변수의값을확인 여러유형의단순한문제를확인할수있음 그러나자세히살펴보기위해서는디버깅툴필요 int main(void) { int count; long large_no; double real_no; init_vars();

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다. C 언어와 Assembly Language 을사용한 Programming 20011.9 경희대학교조원경 1. AVR Studio 에서사용하는 Assembler AVR Studio에서는 GCC Assembler와 AVR Assmbler를사용한다. A. GCC Assembler : GCC를사용하는경우 (WinAVR 등을사용하는경우 ) 사용할수있다. New Project

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

Microsoft PowerPoint oshw1&2.ppt [호환 모드]

Microsoft PowerPoint oshw1&2.ppt [호환 모드] 과제 1 : 기본이해 (4 월 8 일까지 ) 1. 1장 & 2장연습문제풀이 1 1.4 2 1.17 3 2.3 4 2.7 2. 프로그래밍과제 1» 연습문제 2.18 프로그램안에서가능한한많은 system call을사용한다. ptrace, dtrace 시스템호출추적방법은테스트한후수업시간에설명할예정이다. 3. 프로그래밍과제 2 ( 교재 p138 Chapter 3 프로젝트

More information

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서 커알못의 커널 탐방기 2015.12 이 세상의 모든 커알못을 위해서 개정 이력 버전/릴리스 0.1 작성일자 2015년 11월 30일 개요 최초 작성 0.2 2015년 12월 1일 보고서 구성 순서 변경 0.3 2015년 12월 3일 오탈자 수정 및 글자 교정 1.0 2015년 12월 7일 내용 추가 1.1 2015년 12월 10일 POC 코드 삽입 및 코드

More information

제12장 파일 입출력

제12장 파일 입출력 제 4 장파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 시스템호출 (system call) 파일 (file) 임의접근 (random access) 주요학습내용 2 4.1 절 커널의역할 (kernel) 커널 (kernel) 은운영체제의핵심부분으로서, 하드웨어를운영관리하는여러가지서비스를제공함 파일관리 (File management) 디스크 프로세스관리

More information

슬라이드 제목 없음

슬라이드 제목 없음 < > Target cross compiler Target code Target Software Development Kit (SDK) T-Appl T-Appl T-VM Cross downloader Cross debugger Case 1) Serial line Case 2) LAN line LAN line T-OS Target debugger Host System

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

chap8.PDF

chap8.PDF 8 Hello!! C 2 3 4 struct - {...... }; struct jum{ int x_axis; int y_axis; }; struct - {...... } - ; struct jum{ int x_axis; int y_axis; }point1, *point2; 5 struct {....... } - ; struct{ int x_axis; int

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

Microsoft PowerPoint - Chapter_09.pptx

Microsoft PowerPoint - Chapter_09.pptx 프로그래밍 1 1 Chapter 9. Structures May, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 구조체의개념 (1/4) 2 (0,0) 구조체 : 다양한종류의데이터로구성된사용자정의데이터타입 복잡한자료를다루는것을편하게해줌 예 #1: 정수로이루어진 x,

More information

Adding a New Dev file

Adding a New Dev file Adding a New Dev file - 김성영, 이재혁, 김남현 - 발표자 : 김남현 목차 01 Progress 02 Device file 03 How create dev file 04 Example Progress 4 월 1 일 프로젝트방향설정 4 월 8 일 device file 추가방법조사 mem.c 파일분석 4 월 10 일 알고리즘제시필요한함수분석

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 LED Device Control - mmap() Jo, Heeseung 디바이스제어 디바이스제어 HBE-SM5-S4210 에장착된 Peripheral 들은다양한인터페이스로연결되어있음 베이스보드에있는 LED 와 7-Segment 는 GPIO 로직접 CPU 에연결 M3 모듈인 FPGA 모듈은 FPGA 에의해서제어되며 CPU 와호스트버스로연결되어있어서프로그램에서는메모리인터페이스로인식

More information