1 / 12

U nix P roject 2 <test character device 생성 >

U nix P roject 2 <test character device 생성 >. 11 조 061736 이지은 063581 이희은 083771 고연정. C haracter d evice 생성. * open, close, read, write kernel 모듈 작성 * 각각의 모듈을 test device 내에서 user program 을 사용하여 실험 * I/O 는 512B, 1KB, 4KB 의 블록 단위로 수행이 되도록 하여 16M 의 데이터를 write/read 하기 위한 시간을 측정.

peta
Download Presentation

U nix P roject 2 <test character device 생성 >

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix Project2<test character device 생성> 11조 061736 이지은 063581 이희은 083771 고연정

  2. Character device 생성 * open, close, read, write kernel 모듈 작성 * 각각의 모듈을 test device내에서 user program을 사용하여 실험 * I/O는 512B, 1KB, 4KB의 블록 단위로 수행이 되도록 하여 16M의 데이터를 write/read 하기 위한 시간을 측정

  3. Character device 생성 - dev.c * open & close (release) try_module_get/module_put : 모듈사용횟수증가/감소(생략) buff = kmalloc(value, GFP_KERNEL);/ kfree(buff); 메모리할당/해제 * read for(i = 0; i < count; i++) if((err = copy_to_user(buf, buff, value)) < 0) return err; 커널 메모리 buff를 사용자 메모리 buf로 value만큼 복사

  4. Character device 생성 - dev.c * write for(i = 0; i < count; i++){ if((err = copy_from_user(buff, buf+ nOffset, value)) < 0) return err; nOffset += value; } 사용자 메모리 buf+nOffset을 커널 메모리 buff로 value만큼 복사 (nOffset의 위치를 value만큼 이동시켜 다음 값을 buff로 넣음)

  5. Character device 생성 - app.c * #define SIZE = 16777216 * fd = open("data", O_RDWR); * buff = (char*)malloc(SIZE); * dev=open(DEVICE_FILENAME,O_RDWR); * ret = write(dev,buff,SIZE); * ret = read(dev,buff,SIZE); * ret=close(dev); * close(fd);

  6. Character device 생성 Memory buffer User Kernel 16MB Data (512B,1KB,4KB입력) 2.Read (copy_to_user) 1.Write (copy_from_user)

  7. 시간분석(512B,1KB,4KB) * gettimeofday() 함수 이용 : 시간측정 - 현재 system 시간을 가져오는 api (마이크로 초 단위까지 체크가능) >> 큰 차이가 없음

  8. 프로젝트 실행 * 실행하기 • mknod /dev/calldev c 240 1 • insmod call_dev.ko value=(512/1024/4096) • User program 실행(./app) * dmesg>>

  9. 프로젝트 실행 * 실행하기 • mknod /dev/calldev c 240 1 • insmod call_dev.ko value=512 • User program 실행(./app) * 512K로 실행 >>

  10. 프로젝트 실행 * 실행하기 • mknod /dev/calldev c 240 1 • insmod call_dev.ko value=512 • User program 실행(./app) * 1KB로 실행 >>

  11. 프로젝트 실행 * 실행하기 • mknod /dev/calldev c 240 1 • insmod call_dev.ko value=512 • User program 실행(./app) * 4KB로 실행 >>

  12. QNA

More Related