목록운영체제 (22)
수정입니다

inode ? 한 process에서 file을 구분하는 unique한 number The Way To Think file system을 구현하는 방법 1. Data structures linear한 disk를 자료구조를 이용하여 data를 저장하게끔 만듬 2. Access methods file system에 제공할 API 필요 open() read() write() Overall Organization disk의 linear한 공간을, block 단위로 잘라서 사용 Block size = 4KB disk가 커도, file system은 총 64개의 block만 관리 => 총 4KB * 64 = 256KB 관리 Data region in file system user가 write를 했을 때, data를 ..

Semaphore : A definition integer value를 담는 object sem_wait() sem_post() #include sem_t s; sem_init(&s, 0, 1) 두번째 arg 0 : semaphore가 같은 process 내에서는 shared 된다는 의미 세번째 arg 1 : 1로 초기화 sem_wait() int sem_wait(sem_t *s){ decrement the value of semaphore s by one wait if value of semaphore s is negative } sem_wait()이 불리면, semaphore를 하나 감소시킴 (맨 처음 1로 초기화 되어있음) 이후 감소한 semaphore 값이 negaive면 wait을 한다. 0이거..

Conditon variables 한 thread가 다른 thread를 제어하는 목적으로 사용 보통 join() 함수처럼 사용함 대표적인 사용 방식 state variable은 done 을 flag로 사용 하지만 이런식으로 하면, done을 계속 체크하면서 spin-wait 이 되므로 cpu 낭비가 심해짐 Definition and Routines pthread_cond_t c; 대표적인 condition variable 정의 방식 이 안에 queue가 포함 (그냥 queue라고 생각하는게 편할 듯..) How to wait for a condition cpu 낭비를 막기 위해, condition variable에서 두가지 condition 을 설정 1. Waiting on the condition 어떤..

I/O Devices I/O : critical to computer system to interact with systems I/O Architecture Buses : cpu나 ram, I/O devices 사이의 정보를 제공하는 Data path I/O bus : cpu와 I/O devices 사이의 data path 세가지의 hardware components를 연결 I/O ports interfaces device controllers Canonical Device Hardware interface of Canonical Device status register : 현재 device의 상태를 보여줌 command register : 명령어를 받는 reg data register : data를 p..
Building a Lock low cost의 좋은 lock을 위해 hardware와 OS의 도움을 받을 수 있음 Evaluating locks - Basic criteria 1. Mutual exclusion 여러개의 thread를 사용할 때, critical section을 보호할 수 있는지 2. Fairness(Starvation) flag를 누가 catch 했냐에 따라 lock을 잡고 못잡고가 결정 => 운이 안좋으면 계속 못잡을 수도 있음 3. Performance spin waiting을 하면서, 계속 다른 thread가 기다려야 하는 문제 => cpu 낭비 ==> 이러한 문제들을 어떻게 해결할 수 있을까? Controlling Interrupts void lock(){ DisableInter..
Thread Creation #include pthread_t thread; // 미리 thread 변수 생성 ... int pthread_create( pthread_t * thread // 변수 주소값 넘겨서 기록 const pthread_attr_t* attr, void* (*start_routine)(void*), void* arg // void pointer type => argument에 아무 type이나 올 수 있게 해줌 ); /*example*/ // integer argument void* (*start_routine)(int), int arg // return an integer int (*start_routine)(void*) void* arg attr : 여러 속성 기록(보통 nul..

Thread ? a new abstraction for a single running process Multi - threaded program 하나 이상의 execution point를 가지는 program cpu 안에 pc는 하나인데 어떻게 multi thread? => context switching 하는 것 처럼 thread들을 계속 빠른 시기에 바꿔줌 excution point 가 여러개 == PCB의 저장 공간 유무 => 여러 thread가 어디까지 수행했는지를 PCB에 저장해서 알 수 있어야 함 보통 thread 들은 하나의 process에서 address space를 공유한다. => PDBR을 바꿀 필요가 x => page table 바꿀 필요 x => memory 접근 안해도 됨 ==> ..

Paging : Linear Tables 지금까지 배운 page table은 linear한 하나의 table임 만약 PTE의 개수가 늘어나면, page table의 size도 점점 커지게 됨 => 너무 큰 page table size는 memory 공간 낭비 문제가 있다. Paging : Smaller Tables page table 의 size 자체는 큰데, 그 큰 page table을 전부 사용하지 않는 경우도 있음 다 사용하지 않는데 physical에 전부 mapping 하는 것 역시 낭비 => internal fragmentation => 그래서 사용하지 않는 부분은 할당하지 않기로 함 Multi-level Page Tables linear 한 page table을 tree처럼 생각하는 방식 pa..

TLB Part of the chip's memory-management unit(MMU) 자주 쓰이는 PTE를 TLB에 저장하는 방식 cache memory의 일 VA에서 PA 변환하려 page table 보기 전에 TLB를 먼저 보고, TLB에 있으면 굳이 page table을 보려고 memory를 방문하지 않고도, MMU에서 알아서 TLB를 보고 PA로 변환 대신 TLB는 몹시 작다 TLB Basic Algorithms TLB hit이고, accessible 하면 바로 TLB 내부에서 PFN 추출 후 PA 변환 TLB hit이지만 inaccessible이면 exception 발생 TLB miss 나면, page table을 봐서 PTE를 꺼냄 이후 그 miss 난 PTE를 TLB에 insert 하고..

Concept of Paging Paging ? address space를 page라는 fixed-sized unit으로 split up 하는 것 paging을 이용하면 단편화 문제를 해결할 수 있다. page frame physical memory에서의 page page table virtual mem의 page를 physical mem의 page frame으로 mapping 한 정보를 기록해 놓은 곳 process 마다 존재한다. Advantages of Paging Flexibility : supporting the abstraction of address space effectively Simplicity : ease of free-space management Example: A Simple P..