1 Mobile Embedded System Lab. 임베디드시스템설계 서울시립대학교 컴퓨터과학부 이동희 2 Mobile Embedded System Lab. Lecture overview 강의 내용 Embedded System 개발 환경 설치 Embedded System 실습 ARM 프로세서 임베디드 보드 구성 리눅스 커널 빌드 커널 모듈 개발 문자, 블록 디바이스 드라이버 개발 인터럽트 서비스 루틴 개발 고급 블록 디바이스 개발 파일시스템 개발 및 설치 강의자료 다운로드 http://embedded.uos.ac.kr/ 3 Mobile Embedded System Lab. 운영체제 소개 4 Mobile Embedded System Lab. 이 장의 강의 목표 컴퓨터 구조를 이해한다. 운영체제 정의를 이해한다. 운영체제가 관리하는 자원의 유형을 알아본다. 운영체제의 논리적 구조를 이해한다.
20
Embed
운영체제소개 - cfs3.tistory.comcfs3.tistory.com/upload_control/download.blog?f...Mobile Embedded System Lab. 13 운영체제논리적구조(1/2) System Call Interface Buffer
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1Mobile Embedded System Lab.
임베디드시스템설계
서울시립대학교 컴퓨터과학부 이동희
2Mobile Embedded System Lab.
Lecture overview강의 내용
Embedded System 개발 환경 설치
Embedded System 실습ARM 프로세서
임베디드 보드 구성
리눅스 커널 빌드
커널 모듈 개발
문자, 블록 디바이스 드라이버 개발
인터럽트 서비스 루틴 개발
고급 블록 디바이스 개발
파일시스템 개발 및 설치
강의자료 다운로드
http://embedded.uos.ac.kr/
3Mobile Embedded System Lab.
운영체제소개
4Mobile Embedded System Lab.
이장의강의목표
컴퓨터 구조를 이해한다.운영체제 정의를 이해한다.운영체제가 관리하는 자원의 유형을 알아본다. 운영체제의 논리적 구조를 이해한다.
5Mobile Embedded System Lab.
컴퓨터구조 (1/4)
Input device
CPU
Main memory
Secondary storage
Output device
Communication Device
하드웨어
6Mobile Embedded System Lab.
컴퓨터구조 (2/4)하드웨어 구성 요소
중앙 처리 장치 (central processing unit)컴퓨터의 두뇌 : 데이터 연산, 논리 연산 (ALU), 제어(control Unit)레지스터 (register)x86, ARM, PPC, Sparc, Alpha, MIPS, SH4, XScale,
메인 메모리 (memory) : 휘발성
메모리 셀 : 메모리 내의 개별적인 저장 공간
바이트(byte)와 비트(bit)Address Memory Data
저장 장치 (storage device) : 비휘발성
디스크, CD-ROM, 플로피, Flash Memory(NOR, NAND 등)입출력 장치
입력 장치 (input device) : 키보드, 마우스, Key Pad, Touch Screen출력 장치 (output device) : 모니터, 프린터, LCD
통신 장치
모뎀(modem), 이더넷(Ethernet), IrDA, CDMA, Bluetooth
7Mobile Embedded System Lab.
컴퓨터구조 (3/4)소프트웨어
하드웨어
운영체제
응용프로그램
사용자
8Mobile Embedded System Lab.
컴퓨터구조 (4/4)
소프트웨어 구성 요소
운영체제
응용 프로그램
사용자의 특정 목적을 달성하게 하는 소프트웨어
워드프로세서, 게임 소프트웨어, 통신 프로그램
데이터베이스
프로그램 언어, 컴파일러
9Mobile Embedded System Lab.
운영체제정의
운영체제란?
자원 관리자 (Resource Manager)응용에게 자원에 대한 서비스 제공 (Computing Environment)
자원의 종류
물리적인 자원 : 처리기, 메모리, 디스크, 터미널, 네트웍, ...추상적인 자원 : 태스크, 세그먼트/페이지, 파일, 드라이버, 통신 프로토콜, 패킷, 보안, ...
커널과운영체제의차이는?
10Mobile Embedded System Lab.
운영체제종류 (1/3)
IEEE Spectrum 2001, 12월호에서발췌
11Mobile Embedded System Lab.
운영체제종류 (2/3)RTOS
VxWorks, pSOS, LEX, uITRON, EPOCH, PalmOSUNIX
SVR4, SolarisBSD, HP-UX,IBM
LinuxWindows System
Windows XPWindows CE.NETXP Embedded
12Mobile Embedded System Lab.
Linux Details1991 version 0.01 (November 2002, version 2.4.8)핀란드 대학원생 Linus B. Torvalds (23 age)A. Tanenbaum 교수의 Minix 기반(http://www.cs.vu.nl/~ast/minix.html)Philosophy of COPYLEFT(open source)GNU supportVarious Distributions : Redhat, Debian, Slackware, AlzzaMontaVista, Lineo, Gmate, Zaurus, Samsung, IBM, ..
운영체제종류 (3/3)
13Mobile Embedded System Lab.
운영체제논리적구조 (1/2)
System Call Interface
Buffer Cache
Memory Manager
Process ManagerFilesystem Manager
Device Manager Network Manager
Ext2fs proc xiafs
nfs msdos ntfs
Console KBD SCSICD-ROM PCI ethernet
socket Ipv6 IrDA Bluetooth
Paging/Segmentation
Task ManagementSchedulerSignalingIPC
Hardware Interface
process 3
dev1 dev2 dev3 dev4 devn
block character
User Space
Kernel Space
(Source : Linux Kernel Internals)
process nprocess 2process 1
14Mobile Embedded System Lab.
운영체제논리적구조 (2/2)
15Mobile Embedded System Lab.
이장의정리
컴퓨터 하드웨어 구성 요소 이해
컴퓨터 소프트웨어 구성 요소 이해
운영체제 정의 이해
자원 관리자로서 운영체제 이해
운영체제 논리적 구조를 이해
16Mobile Embedded System Lab.
리눅스커널소개와역사
17Mobile Embedded System Lab.
이장의강의목표
리눅스 커널의 역사를 이해한다.리눅스 커널의 특징을 이해한다.리눅스 커널의 2가지 기본 객체를 이해한다. 리눅스 커널의 명령어를 이해한다.리눅스 커널에서 프로그램 개발 과정을 이해한다
18Mobile Embedded System Lab.
리눅스소개 (1/9)리눅스 정의
Univ. of Helsinki in Finland1991년 5월 14일, 0.0.1 버전 출시
현재 안정 버전인 2.4.*, 개발 버전 2.5.*, 안정버전 2.6 출시
Linus Torvalds가 만든 UNIX 계열 운영체제
19Mobile Embedded System Lab.
리눅스소개 (2/9)운영체제란?
자원 관리자 (Resource Manager or Resource Allocator)응용에게 자원에 대한 서비스 제공 (Computing Environment)
자원의 종류
물리적인 자원 : 처리기, 메모리, 디스크, 터미널, 네트워크, ...
추상적인 자원 : 태스크, 세그먼트/페이지, 파일, 드라이버, 통신 프로토콜, 패킷, 보안, ...
운영체제의 목표
EfficiencyFairnessConvenience
20Mobile Embedded System Lab.
리눅스소개 (3/9)UNIX란?
More details and recent information: http://www.levenez.com/unix/POSIX (Portable Operating Systems based on UNIX)
AT&T에서 지속적으로 개발: eg) SVR4.2ESMPBSD: University of California at Berkeley에서 개발
DARPA에서 지원: 정부에서 사용 목적. 그 결과 4BSD VAX용 4.3BSD
CMU’s MACH마이크로 커널 구조
Windows, Mac OS/X 등에 영향
LinuxSolaris, Tru64, FreeBSD5.1
22Mobile Embedded System Lab.
리눅스소개 (5/9)UNIX 철학
Simple is Beautiful.고급 언어로 작성
시분할 시스템(time-sharing system)간단한 명령 해석기(shell) 지원. 다양한 쉘 존재. 사용자의 선호에 따라 선택 가능
트리 구조의 파일 시스템
다양한 장치/객체 들을 파일로 접근 가능
일반 파일은 단지 문자열로 해석(unstructured sequences of bytes)다중 프로세스 지원
소켓 지원
IPC 지원
다양한 CPU 지원
23Mobile Embedded System Lab.
리눅스소개 (6/9)리눅스는?
UNIX 철학 계승 (from MINIX), compatibleCopyleft (GPL)GNU에서 적극 지원 (Thanks to R. Stallman)IBM등의 기업에서 적극 지원
다양한 개발자 지원 (Thanks to Internet)
24Mobile Embedded System Lab.
리눅스소개 (7/9)리눅스 특징 (from the Book of “Running Linux by M.K Dalheimer”)
It’s free: open sourceIt’s popular: ARM, Pentium(II, III, IV), Sparc, Alpha, m68k, PowerPC, MIPS, It’s powerfulIt’s under your control: 내부를 볼 수 있다.It’s robust: say goodbye to the “blue screen”It’s full-featured: multi-thread, advanced networking, GUIIt’s small: 1MB 이하로 커널 구성 가능
It’s big: powerful utilities and applicationsIt’s well documented: LDP (Linux Documentation Projects)It’s sexy: joie de vivre
25Mobile Embedded System Lab.
리눅스소개 (8/9)Distribution (배포판)
Linux kernel, system installation and management utilities, toolsSlackware, Red Hat, DebianRPM Package
GNU GPL(General Public License)Anyone using Linux, or creating their own derivative of Linux, may not make the derived product proprietarysoftware released under the GPL may not be redistributed as a binary-only product
26Mobile Embedded System Lab.
리눅스소개 (9/9)소프트웨어 컴포넌트
KernelTask (Process) Management Main Memory ManagementSecondary Storage ManagementFile ManagementI/O System ManagementNetworkingProtection SystemCommand-Interpreter System
System libraryUtilities and Command
27Mobile Embedded System Lab.
리눅스: 기본개념과용어 (1/9)UNIX
UNIX는 파일이라는 “장소”에 프로세스(태스크)라는 “생명”을제공한다 (by M. Bach, The Design of the UNIX Operating Systems)
파일 (file)stream of bytes많은 객체를 동일한 파일 인터페이스로 접근할 수있다.
프로세스 (process)수행중인 프로그램
스케줄링의 대상
28Mobile Embedded System Lab.
리눅스: 기본개념과용어 (2/9)file related command
파일 생성
vi, gcc, mknod파일 복사/이동
cp, mv파일 바로 가기
ln파일 삭제
rm 파일 내용 보기
more, cat, head, tail, objdump, hexdump파일 속성 제어
chmod, chown, chgrp, touch파일 redirection
>
man으로 모든명령, 함수사용법을볼수있다. cf) section
- section 1: user command- section 2: system call- section 3: library- section 4: special file (fd, hd, tty, pty)- section 5: conf. file (hosts, passwd)- section 6: program (demo, game)- section 7: system file (tcp, raw, groff)- section 8: admin. command- section 9: glossary
cf) 위치: /usr/share/man
cf) –help, info
29Mobile Embedded System Lab.
리눅스: 기본개념과용어 (3/9)
directory related command생성
mkdir이동
cd삭제
rmdir 현재 위치
pwd
디렉터리 (directory)a set of files계층 구조를 제공
home directory, root directory, current directoryrelative path, absolute path
30Mobile Embedded System Lab.
리눅스: 기본개념과용어 (4/9)파일 소유권과 허가
파일마다 permission과 ownership 존재
31Mobile Embedded System Lab.
리눅스: 기본개념과용어 (5/9)process related command
상태 정보
ps, pstree, top파이프 (IPC 예)
|프로세스 생성과 소멸
쉘이 담당 (fork(), exec())kill
32Mobile Embedded System Lab.
리눅스: 기본개념과용어 (6/9)파일 개념의 일반화
정규 파일 뿐만 아니라 장치, IPC 등도 파일로 관리됨
33Mobile Embedded System Lab.
리눅스: 기본개념과용어 (7/9)시스템 호출과 라이브러리
프로그램 코드
라이브러리 루틴
printf()
write() agent
write() 함수
user space
kernel space
시스템 호출 (system call)OS가 직접 제공하는 함수
커널 수준에서 수행됨
라이브러리(library)사용자의 편의를 위해 제공되는 함수들의 집합
사용자 수준에서 수행됨
34Mobile Embedded System Lab.
리눅스: 기본개념과용어 (8/9)S/W 층 구조
35Mobile Embedded System Lab.
리눅스: 기본개념과용어 (9/9)Shell
명령어 해석기(command interpreter)본 교재 “태스크 관리”장 참조
Commands 사용자들은 이미 존재하는 명령어로 시스템과 대호
command: the needed system calls are embedded within the program and do not need to be obvious to the user.
Library프로그래머가 자주 사용하는 오브젝트 파일들의 집합
본 교재 “인터럽트/트랩/시스템 호출”장 참조
36Mobile Embedded System Lab.
리눅스시스템프로그램 (1/7)S/W 개발 단계: 컴파일러/어셈블러/링커/로더/디버거
Input Data Results
Editor
Compiler Linker
Loader
C File
Error Msg Object File
Other Object File & library
Executable FileASM File
Assembler
Debugger
37Mobile Embedded System Lab.
리눅스시스템프로그램 (2/7)프로그래밍 언어 계층 구조 (Language Hierarchy)
Compiled Java programs are platform-neutral bytecodes executed by a Java Virtual Machine (JVM)
Just-In-Time (JIT) compilers increase performance
49Mobile Embedded System Lab.
부록: 운영체제구조 (6/6)운영체제 설계 시 고려사항
User goals: convenient, easy to learn, reliable, safe, and fastSystem goals: easy to design, implement, and maintain, flexible, reliable, error-free, and efficientBalancing between the two goals
Policy and MechanismPolicies(정책): what will be doneMechanisms(기법): how to do somethingPolicy와 Mechanism은 구분되어야 함
50Mobile Embedded System Lab.
Linux 커널소스트리구조및컴파일방법
51Mobile Embedded System Lab.
이장의강의목표
커널이 어떻게 구현되어 있는지 이해한다.Linux 커널의 소스 트리 구조를 이해한다. Linux 커널의 각 소스 디렉터리의 내용을 이해한다. Linux 커널의 컴파일 방법을 이해한다. 새로 컴파일 한 Linux 커널을 이용하여 시스템을 구동 방법을 이해한다.
우선질문하나.. 커널은어떻게컴파일될까?
52Mobile Embedded System Lab.
Linux 커널소스트리구조 (1/2)소스 레벨 구조 (Example of Linux)
/usr/src/linux
Doc
arch
includeinitfs
kernel ipc lib mm
net
scripts
driver
alpha
arm
m68k
mips
ppc
sparc
i386
boot
kernel
lib
math-emu
mm
asm-alpha
asm-arm
asm-i386
...
linux
net
scsi
video
802
appletalk
decnet
ethernet
ipv4
unix
sunrpc
x25...
block
cdrom
char
net
pci
pnp
sbus
scsi
...
sound
video
coda
ext2
hpfs
msdos
nfs
isofs
...
ntfs
커널의논리적인구조와연관성을고려…
53Mobile Embedded System Lab.
Linux 커널소스트리구조 (2/2)Linux 커널의 논리적인 구조
54Mobile Embedded System Lab.
각디렉토리상세설명 (1/6)arch/
CPU 종속적인 부분, 각 처리기 마다 하위 디렉토리로구성됨 (arch/i386, arch/alpha, arch/arm… )arch/i386/boot/
부트스트랩핑 코드
arch/i386/kernel/하드웨어 종속적인 커널 관리 루틴
트랩, 인터럽트 처리 루틴
문맥 교환 루틴
장치 구성, 초기화 루틴
arch/i386/mm/하드웨어 종속적인 메모리 관리 루틴
init/하드웨어 독립적인 커널 초기화 루틴 (start_kernel)태스크 0 (init_task or task[0]) 생성
태스크 1, 2, 3 등 데몬 프로세스 생성
55Mobile Embedded System Lab.
각디렉토리상세설명 (2/6)kernel/
리눅스 커널의 가장 중심적인 디렉토리 (central section of the kernel)하드웨어 독립적인 커널 관리 루틴 (하드웨어 종속적인 커널 관리 루틴은 arch/i386/kernel 디렉토리에 존재)fork, exit 등 태스크 관련 시스템 호출 처리 루틴
스케줄러 (scheduler) 루틴
시그널 처리 (signal handling) 루틴
시간 관리 (time management) 루틴
mm/하드웨어 독립적인 메모리 관리 루틴 (하드웨어 종속적인메모리 관리 루틴은 arch/i386/mm 디렉토리에 존재) 가상 메모리 관리 루틴
페이징 (paging), 스와핑(swapping)
56Mobile Embedded System Lab.
각디렉토리상세설명 (3/6)fs/
가상 파일 시스템 (virtual file system ) 관리 루틴
open, read 등 태스크 관련 시스템 호출 처리 루틴
특정 파일 시스템 관리 루틴은 하위 디렉토리에 존재 (ext2, proc, nfs, msdos, coda, .. )
drivers/장치 드라이버 루틴
drivers/block/ : 블록 장치 드라이버. 예를 들어 IDE 디스크(hd)drivers/char/ : 문자 장치 드라이버. 예를 들어 serial ports, tty, modem, ..)drivers/net : 네트웍 장치 드라이버. 예를 들어 3C509, ...drivers/pci/ : PCI bus 제어
drivers/sound/ : sound card 드라이버
drivers/cdrom/ : CD-ROM 드라이버
drivers/scsi/ : SCSI 인터페이스 관리
57Mobile Embedded System Lab.
각디렉토리상세설명 (4/6)ipc/
프로세스간 통신 루틴세마포어(semaphores), 공유 메모리(shared memory), 메시지 큐(message queues)
net/TCP/IP, ARP 등 네트웍 통신 프로토콜 (네트웍 장치 드라이버는 drivers/net에 존재)소켓 인터페이스
include/커널 헤더하드웨어 독립적인 헤더 : include/linux/ 하드웨어 종속적인 헤더 : include/asm-***/ (예를 들어Intel CPU 종속적인 헤더는 include/asm-i386/ 디렉토리에 존재)
58Mobile Embedded System Lab.
각디렉토리상세설명 (5/6)modules/
커널 모듈 루틴
모듈은 insmod(modprobe), rmmod 등의 명령으로 동적적재/제거 가능
lib/커널 라이브러리 루틴
Doc/커널 문서 디렉토리.
59Mobile Embedded System Lab.
각디렉토리상세설명 (6/6)각 구성요소간에 연동
60Mobile Embedded System Lab.
Linux 커널컴파일 (1/6)커널 컴파일 방법은 다음의 4 단계로 구성
1. 커널 재구성 (configure) : see Documentation/Configuration.help or chapter 3 of “The LINUX Network”)
make config (menuconfig, xconfig, oldconfig)
2. 커널 종속 관계 체크 (dependency check)make dep (make clean)
3. 실제 컴파일(compile)make bzImage (make zImage)
cf) - make bzdisk (#dd bs=8192 if=$(BOOTIMAZGE) of=/dev/fd0)- make zlilo (#cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz)