Synchronization

Size: px
Start display at page:

Download "Synchronization"

Transcription

1 Synchronization

2 Command Execution 명령어수행과운영체제 UNIX: 프로그램이실행한프로세스가종료될때까지대기 Windows: 실행된모든프로세스는각자수행 Enter Loop Enter Loop Yes Another Command? No fork()code Exit Loop Yes Another Command? No Exit Loop CreateProcess()code Wait for Child to Terminate Execute Command (a) synchronization Execute Execute Command Command (b) no synchronization 2

3 FALSE FALSE FALSE TRUE TRUE TRUE 공유변수 Synchronizing Multiple Threads with a Shared Variable 공유변수 (e.g., run Flag) 를이용하여실행되는자식쓰레드를제어 runflag 가 FALSE 가될때까지지정된작업을지속적으로수행 안정적인방법은아님. 따라서안정적이고실용적인방법필요 Initialize CreateThread( ) Wait runtime seconds Thread Work runflag=false runflag? Exit Terminate 3

4 Concurrency( 병행성 ) 하나의자원에여러객체들이동시에접근하는것. 동기화를통해서 Concurrency 문제를해결 Process 관점 순서를정해서자원을사용해야함. Resource 관점 상호배제 : 자원은한 process 만이사용임계구역 (critical section) 내에서는한프로세스가한자원을사용 동기화를하는방법 소프트웨어적방법하드웨어적방법 OS에서지원하는방법 4

5 Critical Section ( 임계구역 ) Definition of Critical Section Two Programs Code for P1 - 어느한시점에서둘이상의프로세스가동시에자원또는데이터를사용하도록지정된영역을의미 shared double balance; Code for P2 balance = balance + amount; balance = balance - amount; Race Condition(critical section problem) 실행상태에있는두개의프로세스가동시에 Resource 에대한접근이나공유메모리 ( 예, balance 공유변수 ) 를놓고경쟁 Mutual Exclusion( 상호배제 ) Race Condition 에있는프로세스가 Critical Section 에진입하기위한전제조건. ( 한번에하나의 Process 만접근 ) 5

6 Two Programs Two Processes Code for P1 Example of Critical Section shared double balance; Code for P1... balance = balance + amount;... Code for P2... balance = balance - amount;... load load add store Code for P2 load load sub store R1, balance R2, amount R1, R2 R1, balance R1, balance R2, amount R1, R2 R1, balance P1 P2 P1 Critical Section CPU Instruction Processing Sequence CPU Instruction P1 :load R1, balance 500 P1: load R2, amount 200 Context Switching! 상호배제위반 P2: load R1, balance P2: load R2, amount P2: sub R1, R2 P2: store R1, balance Context Switching! P1: add R1, R2 P1: store R1, balance Result: balance = 700 Intend Result: balance = 600 Example of Critical Section Value Inconsistency Occur! balance = 500; P1.amout = 200; P2.amout = 100; 6

7 Problem of Critical Section Critical Sections (cont d) Critical Section 의기본필수조건 Mutual Exclusion 항상하나의프로세스만이임계구역에서수행. 임계구역이수행중이면다른프로세스는진입할수없음. Progress 임계구역이수행하는프로세스가없고어떤프로세스가진입하려할때, 임계구역으로바로진입이가능해야하고, 무기한연기될수없음 Bounded Waiting 하나의프로세스가진입을요청하고, 진입이허용될때까지다른프로세스가진입하는회수 ( 시간 ) 에한계를두는것 진입요청한프로세스가기아상태 (starvation) 에빠짐 7

8 Critical Section 문제해결책 경쟁하는모든프로세스들은데이터를공유 각프로세스는 critical section 이라는공통코드를가짐. 하나의프로세스가 critical section 을수행중이면다른프로세스는각각의 critical section 을수행할수없다. 예 ) 은행입출금문제의 Balance 증가 감소 8

9 Mechanisms Possible Mechanisms Software Solution Using Algorithms Hardware Solution Disabling Interrupt Test-And-Set, Swap Using a Lock Variable in Test-And-Set OS Solution Event, Signal Semaphores Monitors Message Passing 9

10 Using Algorithms Critical Section 을가진프로세스의구조 do { entry section critical section exit section reminder section while (1); 10

11 Shared variables: Using Algorithm 1 int turn; turn = 0 으로초기화 turn = i 일때, P i 이 critical section에진입가능 Process P i do { while (turn!= i); // turn 변수의상태정보이용 critical section turn = j; reminder section while (1); 만족조건 : mutual exclusion 불만족조건 : progress turn=0 에서 P 0 가수행중이아닐때, P 1 이진입하려하면진입불가 - 초기화상태 P 1 수행 P 1 진입불가 11

12 Using Algorithm 2 Shared variables: boolean flag[2]; flag [0] = flag [1] = false 로초기화 flag [i] = true 일때, P i 이 critical section 에진입가능 Process P i do { flag[i] = true; // Critical Section 진입준비 A while (flag[j]) ; // 다른프로세스의상태점검 critical section flag [i] = false; // 자신의상태변경 remainder section while (1); 만족조건 : mutual exclusion A 의문장이빠지면조건에위배된다. 불만족조건 : progress P 0 의 flag[0] = true set 직후다중프로그래밍으로인해 P 1 으로전환되어 flag[1] = true set 하면무한루프발생 (progress 위반 ) 12

13 Using Algorithm 3(Peterson) 앞의두알고리즘에서사용된공유변수를모두사용 Process P i do { A B while (1); flag [i] = true; // Critical Section 진입준비 turn = j; // 상태변경 while (flag [j] and turn = j) ; // 2 가지모두점검 flag [i] = false; critical section remainder section 만족조건 : mutual exclusion, progress 두프로세스사이에발생가능한 critical section 을동기화 A, B 2가지중반드시하나는만족하게됨 13

14 Problem of Software Solution 임계구역에진입하기를원하는프로세스 while 문장에의해 busy waiting이발생. CPU 시간을낭비. Busy waiting 이긴경우 임계구역진입을기다리는프로세스를대기상태로전환하는것 (blocking) 이효과적. 14

15 Using Hardware Solution 원자적으로실행 (executed atomically) 중간에인터럽트가되지않는하나의단위로수행됨 Disabling interrupt Test-and-Set 15

16 Disabling Interrupts Hardware Mechanism Hardware Solution Using Interrupts Timer Interrupt 를강제적으로가능 / 불가능하게하여 Context Switching 이발생하지않도록함. 과 영역에서 Interrupt 에의한 Context Switching 이발생하지않음. disableinterrupts(), enableinterrups() : System Call shared double balance; Code for P1 Code for P2... disableinterrupts(); balance = balance + amount; enableinterrupts(); disableinterrupts(); balance = balance - amount; enableinterrupts();... 16

17 Problem of Hardware Solution Problem Disabling Interrupts (cont d) P1 과 P2 의사용만을막고자하였으나, 다른모든 Process 의 Interrupts 가 Disabling 됨. I/O Interrupt 도처리할수없음. 전체 interrupt 를 Disabling 하지않아야함. Interrupts Disabling 이후 Enabling 되는시간을알수없음. P1 이 Interrupts Disabling 수행후, Schedule 의 Context Switching 이발생. 우선순위가낮으면 Process 가다시시작하는시간을알수없음. 17

18 Test-and-Set Test-and-Set 시스템에서제공하는하드웨어명령어 상태를점검 (Test) 하고변경 (Set) TAS 는프로세서에의해서나눠지지않게수행 TAS 수행중에 Lock 변수를사용하여 interrupt 되지않음 18

19 Test-and-Set Mutual Exclusion with Test-and-Set //Test-and-Set 을이용한한계대기상호배제 function Test-and-Set (var target: boolean): boolean; begin Test-and-Set := target; target := true; end; //Test-and-Set 으로상호배제구현 Repeat while Test-and-Set( lock ) do no-op; 임계구역 lock := false; 잔류구역 until false; 19

20 Lock - 1 해결방법 Using a Lock Variable OS 가제공하는공유변수를이용 Critical Section 의진입을 lock 상태정보를이용하여문제해결. 상태정보가 FALSE 이면 TRUE 로변경하며 CS 에진입하고 True 일때 Busy Waiting 상태정보를이용하여 Mutual Exclusion 을성립 shared boolean lock = FALSE; shared double balance; Code for P1 // Acquire the lock while(lock); lock = TRUE; // Execute critical section balance = balance + amount; // Release lock lock = FALSE; Code for P2 // Acquire the lock while(lock); lock = TRUE; // Execute critical section balance = balance - amount; // Release lock lock = FALSE; 20

21 Lock - 2 Code for P1 Using a Lock Variable (Cont d) Lock Variable 진행순서 shared boolean lock = FALSE; shared double balance; Code for P2 // Acquire the lock while(lock); lock = TRUE; // Acquire the lock while(lock); lock = TRUE; 시간 t0 임계영역진입 lock 을얻음 //Execute critical section balance=balance+amount; // Release lock lock = FALSE; //Execute critical section balance=balance-amount; // Release lock lock = FALSE; t1 t2 t3 t4 critical section lock 을양보 lock 을요청하지만다른프로세스가사용중이므로 임계영역진입 lock 을얻음 대기 t5 t6 critical section lock 을양보 21

22 Lock - 3 Using a Lock Variable (Cont d) Problem of a Lock Variable 또다른 race condition 이발생. 즉, Mutual Exclusion 생성하기위한공유변수가 Critical Section 이되는문제가발생. shared boolean lock = FALSE; shared double balance; Process Context Switching Code for P1 // Acquire the lock while(lock); lock = TRUE; // Execute critical section balance = balance + amount; // Release lock lock = FALSE; Code for P2 // Acquire the lock while(lock); lock = TRUE; // Execute critical section balance = balance - amount; // Release lock lock = FALSE; 22

23 Lock Manipulation as a Critical Section shared double amount, balance; /* 공유변수 */ Code shared for int P1 lock = FALSE; Code /* 동기화 for P2변수 */ enter( lock ); enter( lock ); balance = balance + amount; balance = balance + amount; exit( lock ); exit( lock ); 임계영역진입 enter( lock ) { disableinterrupts(); /* wait for lock */ while( lock ) { /* Let interrupt occur */ enableinterrupts(); disableinterrupts(); lock = TRUE; enableinterrupts(); 임계영역빠져나옴 exit( lock ) { disableinterrupts(); lock = FALSE; enableinterrupts(); disableinterrupts() : 인터럽트금지 enableinterrupts() : 인터럽트허용 23

24 Lock variable 사용 1 Windows 에서 MFC 예제 Lock 변수가 TAS 의기능을수행하여문제해결 CCriticalSection g_critical; // 전역변수로선언 function() { AfxBeginThread(ThreadFuncA, NULL); AfxBeginThread(ThreadFuncB, this); UINT ThreadFuncA(LPVOID pparam) { while(1) { g_critical.lock(); // Critical Section g_critical.unlock(); return 0; UINT ThreadFuncB(LPVOID pparam) { while(1) { g_critical.lock(); // Critical Section g_critical.unlock(); return 0; ThreadFuncA 를작업자스레드로생성하며, 보안특성은기본값 (NULL) 로설정 ThreadFuncB 를작업자스레드로생성하며, 보안특성은현재프로세스로부터상속 * 보안특성은사용자, 그룹등의권한정보로윈도우에서는 SECURITY_ATTRIBUTES 구조체로표현 24

25 Lock variable 사용 2 Linux 에서 C++ 예제 Linux thread 프로그램에서 LinuxThreads 가제공하는것은쓰레드루틴들의프로토타입을선언하는 /usr/include/pthread.h 헤더를통해서이용가능 #include <pthread.h> 동기화객체로사용할 lock을선언... pthread_mutex_t lock; pthread_mutex_init(&lock, NULL);... 공유변수들에 lock 을걸고쓰레드를만들기위한 pthread 루틴들을사용한다. pthreads_mutex_lock( &lock ); /* Critical Section */ pthreads_mutex_unlock( &lock ); 동기화객체의초기화 25

26 Semaphore - 1 Dijkstra Semaphore Semaphore 1960 년대, 동기화를해결하려는시도로개념적인이론 개념적인이론으로 P(), V() Operation 과같은의사코드임. 기본적으로 Process 기반으로작성. Thread 에서도적용가능하여대부분의 OS 동기화방법들의기초가됨. Semaphore 의종류 Counting Semaphore (integer value) 다수의프로세스들이동시에임계구역을수행가능 Binary (0, 1 or true, false) Semaphore 값의상태에따른수행증가 Semaphore보다간편한구현 26

27 Semaphore - 2 Dijkstra Semaphore (Cont d) Hardware/Software 모두적용가능 In semaphore, S 값 ( 세마포어변수 ) 은양수의숫자값으로 2 가지나눠지지않는 (Atomic) 함수에서만조작이가능 P(), V() Operation 은 Atomic 하다고가정. V(): Mutual Exclusion 상태에서 S 값이증가하는 Operation 즉, 실제 Critical Section 의수행. P(): S 값을검사하고대기하거나수행하는 Operation V(S): [S = S + 1] // 실행 P(S): [while(s == 0) {wait; S = S - 1] // 대기후감소 27

28 Processes Condition for Semaphore Dijkstra Semaphore (Cont d) Cooperating Processes 여러개의 Processes 가협동하며처리하기위한기본구성. <shared global declarations> 에처리할공유변수선언. fork() 이후의코드는순차적으로수행되는코드가순환하는형태를취해야함. Proc_0() { Proc_1() { while (TRUE) { while (TRUE) { 순환함 <compute section>; <critical section>; 순차적임 <compute section>; <critical section>; <shared global declarations> <initial processing> fork(proc_0, 0); fork(proc_1, 0); 28

29 Assumptions of Semaphore and Mutex Dijkstra Semaphore (Cont d) 해결방법에대한가정 메모리읽기 / 쓰기는나누어지지않음 (Invisible, Atomic). 프로세스간우선순위는존재하지않음프로세스와프로세서의속도는제외. 프로세스는순차적으로순환하는형태. Mutex Mutex 는 Binary Semaphore 임. Mutex 를 Lock 한프로세스만이 Unlock 가능 29

30 Basic Concept of Semaphore Code Dijkstra Semaphore (Cont d) Semaphore 의기본코드 (Skeleton Code) Cooperating Process의구조. Critical Section에진입하기전에반드시점검. Proc_0() { while (TRUE) { <compute section>; P(mutex); <critical section>; V(mutex); Proc_1() { while (TRUE) { <compute section>; P(mutex); <critical section>; V(mutex); semaphore mutex = 1; fork(proc_0, 0); fork(proc_1, 0); 30

31 Semaphore Code for Shared Account Problem Dijkstra Semaphore (Cont d) Semaphore 를이용한공유변수문제해결 Proc_0() { // Enter the CS P(mutex); Proc_1() { // Enter the CS P(mutex); balance = balance + amount; balance = balance - amount; // Exit the CS V(mutex); // Exit the CS V(mutex); semaphore mutex = 1; fork(proc_0, 0); fork(proc_1, 0); 31

32 Semaphore Code for Two Shared Variables Dijkstra Semaphore (Cont d) 2 개의프로세스간의동기화문제해결 Proc_A() { while(true) { <compute section A1>; update(x); // Signal to Proc_B V(s1); <compute section A2>; // Wait for Proc_B P(s2); retrieve(y); semaphore s1 = 0; semaphore s2 = 0; fork(proc_a, 0); fork(proc_b, 0); Proc_B() { while(true) { // Wait for Proc_A P(s1); retrieve(x); <compute section B1>; update(y); // Signal to Proc_A V(s2); <compute section B2>; Update 되기를기다려야하므로세마포어변수를 0 으로 Set 실행과정 1. Proc_B 는 에서 blocking 2. Proc_A 는 까지단독실행 3. Proc_A 의 ~ 사이의코드와 Proc_B 의 이후의코드가동시에실행 4. Proc_A 는 Proc_B 의 를실행할때까지 에서대기 5. Proc_B의 를실행한후 Proc_A의 이후의코드를실행 32

33 AND Synchronization Definition of AND Synchronization AND Synchronization Problem 문제정의다수의프로세스에의해동시접근될수있는자원이여러개존재각프로세스가수행되려면두개이상의자원을모두소유해야함문제 semaphore 의경우두개이상의자원에대한중첩된 lock 을사용할경우, Deadlock 이발생함. Semaphore mutex1 = 1; Semaphore mutex2 = 1; 중첩된 lock P(mutex1); 서로 lock을요청 P(mutex2); Deadlock 발생 Critical Section V(mutex1); V(mutex2); P(mutex2); P(mutex1); Critical Section V(mutex2); V(mutex1); 해결방법 p(),v() operation 을 ordering 한추상화된 semaphore 사용 P simultaneous (S 1,, S n ) 33

34 Conceptual Code of AND Synchronization AND Synchronization (cont.) Concept Code 모든자원에대해 AND 조건즉, 모두사용이가능한상태에서동기화하는방법. semaphore mutex = 1; semaphore block = 0; P.sim(int S, int R) { P(mutex); S--; R--; V.sim(int S, int R) { P(mutex); S++; R++; if((s < 0) (R < 0)) { V(mutex); P(block); else V(mutex); unlock S, R 둘중하나라도사용할자원이없으면 block if(((s >= 0) && (R >= 0)) && ((S == 0) (R == 0))) V(block); V(mutex); S, R 둘다 1 개이상의여분의자원을가지고있고, S,R 둘중하나또는둘다 1 개의자원을소유 ( 예, S == 0 or R == 0) 하게되었을때 34

35 Dijkstra Semaphore (Cont d) Semaphore 는논리적으로 Device Controller 에서 busy 와 done 으로사용 Driver 는 controller 에게 V(busy) signal 을보내고, P(done) 이완료될때까지대기 Controller는실행을위해 P(busy) 상태를기다리고, V(done) 가완료됨을알림.... busy done Error code... busy done Idle finished working (undefined) Command Status Data 0 Logic Data 1 Data n-1 35

36 Semaphore Example Code in the Driver-Controller Interface Dijkstra Semaphore (Cont d) 세마포어개념을이용한 Driver-Controller 예제 driver() { <preparation for device operation> // Start the device V(busy); // Wait for the device to complete P(done); <complete the operation> controller() { while (TRUE) { // Wait for a start signal P(busy); <perform the operation> // Tell driver // that H/W has competed V(done); // Map the hardware flags to software shared semaphores semaphore busy = 0; semaphore done = 0; 36

37 Using Semaphore (Cont d) Readers-Writers Problem( 성격이다른 Processes 간의동기화문제 ) 다수의 Reader 와다수의 Writer 존재 Semaphore Solution for Different Processes Property Reader 들은 Shared Resource 에동시에접근할수있음 단, 하나의 Reader 라도 Shared Resource 를사용하고있다면 Writer 는 Shared Resource 에접근할수없음 하나의 Writer 라도 Shared Resource 에접근하고있으면, 다른 Writer 와모든 Reader 는 Shared Resource 에접근할수없음 Reader Reader Reader Reader Reader Reader Reader Reader Shared Resource Request Writer Writer Writer Writer Writer Writer Writer 37

38 Semaphore Code for Different Processes Property: Case 1 Using Semaphore (Cont d) Readers wait for update reader() { while(true) { <other computing>; P(mutex); readcount++; if(readcount == 1) P(writeBlock); // 최초의 reader 는 writer 와경쟁 V(mutex); // Critical section A access(resource); P(mutex); readcount--; if(readcount == 0) V(writeBlock); // 마지막 reader 는 writer 에게 signal 전송 V(mutex); resourcetype *resource; int readcount = 0; semaphore mutex = 1; semaphore writeblock = 1; fork(reader, 0); fork(writer, 0); writer() { while(true) { <other computing>; P(writeBlock); B // 모든 writer 는 reader 가없을때까지대기 // Critical section access(resource); V(writeBlock); Problem A B Writer is Blocked 에서 Readers 는 writer 가데이터를 update 해주기를기대함 에서 Writer 는모든 readers 가작업을끝낼때까지무한정대기함 writeblock 은동기화목적으로사용 mutex는 Mutual Exclusion을위해사용 38

39 Problem of Semaphore for Different Processes Property: Case 1 Using Semaphore (Cont d) Problem of First Reader / Writer Writer가다시자원을사용할수없는경우가발생가능모든 reader가작업이끝날때까지 writer는대기 (Bounded Waitng Problem) Resource Accessing Reader Reader Reader Writer Reader Reader... 도착순서 : Waiting Queuing Sequence 39

40 reader() { while(true) { <other computing>; P(writePending); P(readBlock); P(mutex1); readcount++; if(readcount == 1) P(writeBlock); V(mutex1); V(readBlock); V(writePending); access(resource); P(mutex1); readcount--; if(readcount == 0) V(writeBlock); V(mutex1); Using Semaphore (Cont d) writer() { while(true) { <other computing>; P(mutex2); writecount++; if(writecount == 1) P(readBlock); V(mutex2); P(writeBlock); access(resource); V(writeBlock); P(mutex2); writecount--; if(writecount == 0) V(readBlock); V(mutex2); int readcount = 0, writecount = 0; semaphore mutex1 = 1, mutex2 = 1; semaphore readblock = 1, writeblock = 1, writepending = 1; fork(reader, 0); fork(writer, 0); Semaphore Code for Different Processes Property: Case 2 실행과정 1. 에서 writer 가 readblock 을잡음 2. 에서데이터에 access 중인 readers 가작업을완료할때까지 writer 는대기함 3. 에서데이터에접근중인 reader 가없다면 writeblock lock 을풀어줌 4. 하나의 writer 가 update 작업을수행함 writer 에게높은우선순위를주는방법 에의해서 reader 가 readblock 를잡는시간이지연됨 writepending : 동기화목적 readblock : writer 에게우선순위부여 40

41 Semaphore Code for Different Processes Property: Case 2 Using Semaphore (Cont d) Problem of Precedence Reader / Writer Reader 가다시자원을사용할수없는경우발생. 도착한순서에상관없이 Writer 는앞선 writer 가종료되는순간 Resource 를사용한다.,, 의순서에따름. 먼저도착한 Reader 는우선순위가낮아무조건대기상태발생. Resource Waiting Waiting Waiting Waiting Writer Reader Reader Writer Reader Reader Writer... 도착순서 : Queuing Sequence 41

42 Bounded Buffer Using Semaphore Semaphore Solution for Bounded Buffer 생산자는 empty buffer pool 에서한개의빈 buffer 를가져와정보를채워 full buffer pool 에둠 소비자는반대로 full buffer pool 에서한개의 buffer 를꺼내와정보를얻고, 재활용을위해그버퍼를 empty buffer pool 에둠 빈 buffer 가없을때는생산자의진행을막음또는채워진 buffer 가없을때는소비자의진행을못막음. P(empty) : Empty Pool 확인 생산자 Empty Buffer Pool 소비자 V(empty) : Empty Pool 사용 V(full) : Full Pool 사용 Full Buffer Pool P(full) : Full Pool 확인 42

43 Semaphore Solution for Bounded Buffer Using Semaphore (Cont d) Bounded Buffer 해결 producer() { buf_type *next, *here; while(true) { produce_item(next); // Claim an empty 1 P(empty); P(mutex); here = obtain(empty); V(mutex); copy_buffer(next, here); P(mutex); release(here, fullpool); V(mutex); // Signal a full buffer V(full); consumer() { buf_type *next, *here; while(true) { // Claim full buffer 2 P(full); P(mutex); here = obtain(full); V(mutex); copy_buffer(here, next); P(mutex); release(here, emptypool); V(mutex); // Signal an empty buffer V(empty); consume_item(next); semaphore mutex = 1; buf_type buffer[n]; semaphore full = 0; // A general (counting) semaphore semaphore empty = N;// A general (counting) semaphore fork(producer, 0); fork(consumer, 0); Problem 1 소비자는생산자가가데이터를 update 해주기를기대함 2 생산자는모든소비자가작업을 끝낼때까지무한정대기함 empty 와 full 은동기화목적으로사용 mutex 는 empty / full Mutual Exclusion 을위해사용 43

44 Semaphore Code for Bounded Buffer in Trouble Using Semaphore (Cont d) 실수에의한중첩 Lock 의사용 에서 mutex lock 을소유한상태에서 full lock 을요구하고있음 Deadlock producer() { buf_type *next, *here; while(true) { produce_item(next); // Claim an empty P(empty); P(mutex); here = obtain(empty); V(mutex); copy_buffer(next, here); P(mutex); release(here, fullpool); V(mutex); // Signal a full buffer V(full); Deadlock consumer() { buf_type *next, *here; while(true) { // Claim full buffer P(mutex); P(full); here = obtain(full); V(mutex); copy_buffer(here, next); P(mutex); release(here, emptypool); V(mutex); // Signal an empty buffer V(empty); consume_item(next); semaphore mutex = 1; buf_type buffer[n]; semaphore full = 0; // A general (counting) semaphore semaphore empty = N;// A general (counting) semaphore fork(producer, 0); fork(consumer, 0); 44

45 Implementing Semaphores I/O 시스템에대한영향을최소화 프로세스들은자신이임계영역에있을때만블록됨 인터럽트가금지되어있으면, 인터럽트금지시간의한계를정할것 45

46 Implementing Semaphores: enter() & exit() class semaphore { int value; public: semaphore(int v = 1) { value = v;; P(){ disableinterrupts(); while(value == 0) { enableinterrupts(); disableinterrupts(); value--; enableinterrupts(); ; V(){ disableinterrupts(); value++; enableinterrupts(); ; ; 46

47 Using the TS Instruction boolean s = FALSE;... while(ts(s)) ; <critical section> s = FALSE;... semaphore s = 1;... P(s) ; <critical section> V(s);... Counting Semaphore 가안됨 47

48 Implementing the General Semaphore struct semaphore { int value = <initial value>; boolean mutex = FALSE; boolean hold = TRUE; ; shared struct semaphore s; P(struct semaphore s) { while(ts(s.mutex)) ; s.value--; if(s.value < 0) ( s.mutex = FALSE; while(ts(s.hold)) ; else s.mutex = FALSE; V(struct semaphore s) { while(ts(s.mutex)) ; s.value++; if(s.value <= 0) ( while(!s.hold) ; s.hold = FALSE; s.mutex = FALSE; 48

49 Busy-Waiting Condition While(TS(s.hold)); while(ts(s.hold)) yield( *, scheduler ); yield() : 자신의프로세스사용시간을양보 - busy waiting 하지않고다른프로세스가수행됨 49

50 Active vs Passive Semaphores A process can dominate the semaphore Performs V operation, but continues to execute Performs another P operation before releasing the CPU Called a passive implementation of V Active implementation calls scheduler as part of the V operation. Active Semaphore V 후 wait 한프로세스에게권한양보 Passive Semaphore V 후자신이계속수행 50

51 Problem of Semaphore 상호배제 (mutual exclusion) 와프로세스동기화에유용한도구. 상호배제 : set 1 동기화 : set 0 P(S) 와 V(S) 가여러프로세스사이에분산될수있어전체적인동작의이해가어려움. 모든프로세스들이 Semaphore 의정상적사용필요. 하나의프로세스에서 Semaphore 사용에오류가발생하면전체프로세스가실패할수있음. 51

10주차.key

10주차.key 10, Process synchronization (concurrently) ( ) => critical section ( ) / =>, A, B / Race condition int counter; Process A { counter++; } Process B { counter ;.. } counter++ register1 = counter register1

More information

Microsoft PowerPoint - o6.pptx

Microsoft PowerPoint - o6.pptx 목표 6 장. 프로세스동기화 임계구역 (Critical Region) 문제소개 이문제에대한해결책은공유데이터의일관성유지에사용가능 임계구역문제의하드웨어및소프트웨어해결책제시 전통적인프로세스동기화문제소개 프로세스동기화문제해결에사용되는도구조사 2 6.1 배경 생산자 - 소비자문제 공유데이터사용 협력프로세스 (Cooperating process) 다른프로세스의실행을영향을주거나받는프로세스

More information

Microsoft PowerPoint - StallingsOS6e-Chap05.pptx

Microsoft PowerPoint - StallingsOS6e-Chap05.pptx 5 장병행성 : 상호배제와동기화 5 장의강의목표 병행성 (concurrency) 의원리와주요용어를이해한다. 경쟁상태 (race condition) 의문제점에대해이해한다. 상호배제 (mutual exclusion), 교착상태 (deadlock), 기아상태 (starvation) 의 3 가지제어문제를이해한다. 상호배제를보장하기위한하드웨어적접근방법을이해한다. 세마포어를이용한상호배제기법을이해한다.

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

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

Abstract View of System Components

Abstract View of System Components 운영체제실습 - Synchronization - Real-Time Computing and Communications Lab. Hanyang University jtlim@rtcc.hanyang.ac.kr dhchoi@rtcc.hanyang.ac.kr beespjh@gmail.com Introduction 조교소개 이름 : 임정택 Tel : 010-4780

More information

Microsoft PowerPoint - StallingsOS6e-Chap06.ppt [호환 모드]

Microsoft PowerPoint - StallingsOS6e-Chap06.ppt [호환 모드] 6 장병행성 : 교착상태와기아 6 장의강의목표 교착상태 (deadlock) 의원리를이해한다. 교착상태에자원할당그래프가어떻게이용되는지이해한다. 교착상태가발생하기위한필요. 충분조건을이해한다. 교착상태예방기법들을이해한다. 교착상태회피기법들을이해한다. 교착상태의발견과복구기법들을이해한다. 식사하는철학자문제를이해하고해결방법을이해한다. UNIX, LINUX, Solaris,

More information

입학사정관제도

입학사정관제도 운영체제 강의노트 교재 : 운영체제 ( 개정판 ) 출판사 : 한빛미디어 (2010 년 11 월발행 ) 저자 : 구현회 소프트웨어학과원성현교수 1 4 장 병행프로세스와 상호배제 소프트웨어학과원성현교수 2 1. 병행프로세스 병행프로세스의과제 병행성 동시에 2 개이상의프로세스가실행되는성질 다중프로세싱시스템, 분산처리시스템에서주로발생 다중프로세싱시스템은프로세서의효율성을증대시킴

More information

Microsoft PowerPoint - o6.pptx

Microsoft PowerPoint - o6.pptx Dining-Philosophers Problem 세마포사용 Semaphore chopstick[5] = {1,1,1,1,1} ; // initially all values are 1 Philosopher i while (true) { P(chopStick[i]); // get left chopstick P(chopStick[(i+1) % 5]); // get

More information

Microsoft PowerPoint - o6.pptx

Microsoft PowerPoint - o6.pptx Dining-Philosophers Problem 세마포사용 6.8 모니터 (Monitors) Semaphore chopstick[5] = {1,1,1,1,1 ; // initially all values are 1 Philosopher i while (true) { P(chopStick[i]); // get left chopstick P(chopStick[(i+1)

More information

제11장 프로세스와 쓰레드

제11장 프로세스와 쓰레드 제9장자바쓰레드 9.1 Thread 기초 (1/5) 프로그램 명령어들의연속 (a sequence of instruction) 프로세스 / Thread 실행중인프로그램 (program in execution) 프로세스생성과실행을위한함수들 자바 Thread 2 9.1 Thread 기초 (2/5) 프로세스단위작업의문제점 프로세스생성시오버헤드 컨텍스트스위치오버헤드

More information

Chap06(Interprocess Communication).PDF

Chap06(Interprocess Communication).PDF Interprocess Communication 2002 2 Hyun-Ju Park Introduction (interprocess communication; IPC) IPC data transfer sharing data event notification resource sharing process control Interprocess Communication

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.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 학습목표 을 작성하면서 C 프로그램의

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

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

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

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Reasons for Poor Performance Programs 60% Design 20% System 2.5% Database 17.5% Source: ORACLE Performance Tuning 1 SMS TOOL DBA Monitoring TOOL Administration TOOL Performance Insight Backup SQL TUNING

More information

Module 7: Process Synchronization

Module 7:  Process Synchronization Chapter 6: Process Synchronization ( 프로세스동기화 ), Hanbat National Univ. Computer Eng. Dept. Y.J.Kim 2010 Module 6: Synchronization( 동기화 ) Background( 배경 ) The Critical-Section Problem( 임계구역문제 ) Peterson

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

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

Module 7: Process Synchronization

Module 7:  Process Synchronization Chapter 6: Process Synchronization ( 프로세스동기화 ), Hanbat National Univ. Computer Eng. Dept. Y.J.Kim 2010 Module 6: Synchronization( 동기화 ) Background( 배경 ) The Critical-Section Problem( 임계구역문제 ) Peterson

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for 2003 Development of the Software Generation Method using Model Driven Software Engineering Tool,,,,, Hoon-Seon Chang, Jae-Cheon Jung, Jae-Hack Kim Hee-Hwan Han, Do-Yeon Kim, Young-Woo Chang Wang Sik, Moon

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

歯엑셀모델링

歯엑셀모델링 I II II III III I VBA Understanding Excel VBA - 'VB & VBA In a Nutshell' by Paul Lomax, October,1998 To enter code: Tools/Macro/visual basic editor At editor: Insert/Module Type code, then compile by:

More information

HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M.

HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M. 오늘할것 5 6 HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M. Review: 5-2 7 7 17 5 4 3 4 OR 0 2 1 2 ~20 ~40 ~60 ~80 ~100 M 언어 e ::= const constant

More information

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D> 뻔뻔한 AVR 프로그래밍 The Last(8 th ) Lecture 유명환 ( yoo@netplug.co.kr) INDEX 1 I 2 C 통신이야기 2 ATmega128 TWI(I 2 C) 구조분석 4 ATmega128 TWI(I 2 C) 실습 : AT24C16 1 I 2 C 통신이야기 I 2 C Inter IC Bus 어떤 IC들간에도공통적으로통할수있는 ex)

More information

슬라이드 1

슬라이드 1 마이크로컨트롤러 2 (MicroController2) 2 강 ATmega128 의 external interrupt 이귀형교수님 학습목표 interrupt 란무엇인가? 기본개념을알아본다. interrupt 중에서가장사용하기쉬운 external interrupt 의사용방법을학습한다. 1. Interrupt 는왜필요할까? 함수동작을추가하여실행시키려면? //***

More information

Microsoft PowerPoint - chap05-제어문.pptx

Microsoft PowerPoint - chap05-제어문.pptx int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); 1 학습목표 제어문인,, 분기문에 대해 알아본다. 인 if와 switch의 사용 방법과 사용시 주의사항에 대해 알아본다.

More information

제4장 기본 의미구조 (Basic Semantics)

제4장  기본 의미구조 (Basic Semantics) 제 4 장블록및유효범위 Reading Chap. 5 숙대창병모 1 4.1 변수선언및유효범위 숙대창병모 2 변수선언과유효범위 변수선언 Declaration before Use! 대부분의언어에서변수는사용전에먼저선언해야한다. 변수의유효범위 (scope) 선언된변수가유효한 ( 사용될수있는 ) 프로그램내의범위 / 영역 변수이름뿐아니라함수등다른이름도생각해야한다. 정적유효범위

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

ESP1ºÎ-04

ESP1ºÎ-04 Chapter 04 4.1..,..,.,.,.,. RTOS(Real-Time Operating System)., RTOS.. VxWorks(www.windriver.com), psos(www.windriver.com), VRTX(www.mento. com), QNX(www.qnx.com), OSE(www.ose.com), Nucleus(www.atinudclus.

More information

PRO1_04E [읽기 전용]

PRO1_04E [읽기 전용] Siemens AG 1999 All rights reserved File: PRO1_04E1 Information and S7-300 2 S7-400 3 EPROM / 4 5 6 HW Config 7 8 9 CPU 10 CPU : 11 CPU : 12 CPU : 13 CPU : / 14 CPU : 15 CPU : / 16 HW 17 HW PG 18 SIMATIC

More information

Chap 6: Graphs

Chap 6: Graphs 5. 작업네트워크 (Activity Networks) 작업 (Activity) 부분프로젝트 (divide and conquer) 각각의작업들이완료되어야전체프로젝트가성공적으로완료 두가지종류의네트워크 Activity on Vertex (AOV) Networks Activity on Edge (AOE) Networks 6 장. 그래프 (Page 1) 5.1 AOV

More information

Chap04(Signals and Sessions).PDF

Chap04(Signals and Sessions).PDF Signals and Session Management 2002 2 Hyun-Ju Park (Signal)? Introduction (1) mechanism events : asynchronous events - interrupt signal from users : synchronous events - exceptions (accessing an illegal

More information

Modern Javascript

Modern Javascript ES6 - Arrow Function Class Template String Destructuring Default, Rest, Spread let, const for..of Promises Module System Map, Set * Generator * Symbol * * https://babeljs.io/ Babel is a JavaScript compiler.

More information

Frama-C/JESSIS 사용법 소개

Frama-C/JESSIS 사용법 소개 Frama-C 프로그램검증시스템소개 박종현 @ POSTECH PL Frama-C? C 프로그램대상정적분석도구 플러그인구조 JESSIE Wp Aorai Frama-C 커널 2 ROSAEC 2011 동계워크샵 @ 통영 JESSIE? Frama-C 연역검증플러그인 프로그램분석 검증조건추출 증명 Hoare 논리에기초한프로그램검증도구 사용법 $ frama-c jessie

More information

Figure 5.01

Figure 5.01 Chapter 4: Threads Yoon-Joong Kim Hanbat National University, Computer Engineering Department Chapter 4: Multithreaded Programming Overview Multithreading Models Thread Libraries Threading Issues Operating

More information

Microsoft PowerPoint - PL_03-04.pptx

Microsoft PowerPoint - PL_03-04.pptx Copyright, 2011 H. Y. Kwak, Jeju National University. Kwak, Ho-Young http://cybertec.cheju.ac.kr Contents 1 프로그래밍 언어 소개 2 언어의 변천 3 프로그래밍 언어 설계 4 프로그래밍 언어의 구문과 구현 기법 5 6 7 컴파일러 개요 변수, 바인딩, 식 및 제어문 자료형 8

More information

CompareAndSet(CAS) 함수는 address 주소의값이 oldvalue 인지비교해서같으면 newvalue 로 바꾼다. 소프트웨어 lock 을사용하는것이아니고, 하드웨어에서제공하는기능이므로더빠르고 간편하다. X86 에서는 _InterlockedCompareEx

CompareAndSet(CAS) 함수는 address 주소의값이 oldvalue 인지비교해서같으면 newvalue 로 바꾼다. 소프트웨어 lock 을사용하는것이아니고, 하드웨어에서제공하는기능이므로더빠르고 간편하다. X86 에서는 _InterlockedCompareEx NON-BLOCKING ALGORITHM Homepage: https://sites.google.com/site/doc4code/ Email: goldpotion@outlook.com 2011/10/23 멀티쓰레드환경에서알아두면유용한자료구조에대해소개해본다. HARDWARE PRIMITIVE 효율적인구현을위해, Hardware 에서제공하는기능을이용해야한다. 자주쓰는기능에대해

More information

untitled

untitled CAN BUS RS232 Line CAN H/W FIFO RS232 FIFO CAN S/W FIFO TERMINAL Emulator COMMAND Interpreter PROTOCOL Converter CAN2RS232 Converter Block Diagram > +- syntax

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

Something that can be seen, touched or otherwise sensed

Something that can be seen, touched or otherwise sensed Something that can be seen, touched or otherwise sensed Things about an object Weight Height Material Things an object does Pen writes Book stores words Water have Fresh water Rivers Oceans have

More information

03_queue

03_queue Queue Data Structures and Algorithms 목차 큐의이해와 ADT 정의 큐의배열기반구현 큐의연결리스트기반구현 큐의활용 덱 (Deque) 의이해와구현 Data Structures and Algorithms 2 큐의이해와 ADT 정의 Data Structures and Algorithms 3 큐 (Stack) 의이해와 ADT 정의 큐는 LIFO(Last-in,

More information

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 비트연산자 1 1 비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 진수법! 2, 10, 16, 8! 2 : 0~1 ( )! 10 : 0~9 ( )! 16 : 0~9, 9 a, b,

More information

Java ...

Java ... 컴퓨터언어 1 Java 제어문 조성일 조건문 : if, switch 어떠한조건을조사하여각기다른명령을실행 if 문, switch 문 if 문 if - else 문형식 if 문형식 if ( 조건식 ) { 명령문 1; 명령문 2;... if ( 조건식 ) { 명령문 1; 명령문 2;... else { 명령문 a; 명령문 b;... 예제 1 정수를입력받아짝수와홀수를판별하는프로그램을작성하시오.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate ALTIBASE HDB 6.1.1.5.6 Patch Notes 목차 BUG-39240 offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG-41443 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate 한뒤, hash partition

More information

chap01_time_complexity.key

chap01_time_complexity.key 1 : (resource),,, 2 (time complexity),,, (worst-case analysis) (average-case analysis) 3 (Asymptotic) n growth rate Θ-, Ο- ( ) 4 : n data, n/2. int sample( int data[], int n ) { int k = n/2 ; return data[k]

More information

UI TASK & KEY EVENT

UI TASK & KEY EVENT KEY EVENT & STATE 구현 2007. 1. 25 PLATFORM TEAM 정용학 차례 Key Event HS TASK UI TASK LONG KEY STATE 구현 소스코드및실행화면 질의응답및토의 2 KEY EVENT - HS TASK hs_task keypad_scan_keypad hs_init keypad_pass_key_code keypad_init

More information

Chapter ...

Chapter ... Chapter 4 프로세서 (4.9절, 4.12절, 4.13절) Contents 4.1 소개 4.2 논리 설계 기초 4.3 데이터패스 설계 4.4 단순한 구현 방법 4.5 파이프라이닝 개요*** 4.6 파이프라이닝 데이터패스 및 제어*** 4.7 데이터 해저드: 포워딩 vs. 스톨링*** 4.8 제어 해저드*** 4.9 예외 처리*** 4.10 명령어 수준

More information

쓰레드 (Thread) 양희재교수 / 경성대학교컴퓨터공학과

쓰레드 (Thread) 양희재교수 / 경성대학교컴퓨터공학과 쓰레드 (Thread) 양희재교수 (hjyang@ks.ac.kr) / 경성대학교컴퓨터공학과 Thread? 쓰레드 (Thread) 프로그램내부의흐름, 맥 class Test { public static void main(string[] args) { int n = 0; int m = 6; System.out.println(n+m); while (n < m) n++;

More information

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf(hihi\n); } warning: conflicting types for functiona 이름 : 학번 : A. True or False: 각각항목마다 True 인지 False 인지적으세요. 1. (Python:) randint 함수를사용하려면, random 모듈을 import 해야한다. 2. (Python:) '' (single quote) 는한글자를표현할때, (double quote) 는문자열을표현할때사용한다. B. 다음에러를수정하는방법을적으세요.

More information

슬라이드 1

슬라이드 1 Pairwise Tool & Pairwise Test NuSRS 200511305 김성규 200511306 김성훈 200614164 김효석 200611124 유성배 200518036 곡진화 2 PICT Pairwise Tool - PICT Microsoft 의 Command-line 기반의 Free Software www.pairwise.org 에서다운로드후설치

More information

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

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

More information

T100MD+

T100MD+ User s Manual 100% ) ( x b a a + 1 RX+ TX+ DTR GND TX+ RX+ DTR GND RX+ TX+ DTR GND DSR RX+ TX+ DTR GND DSR [ DCE TYPE ] [ DCE TYPE ] RS232 Format Baud 1 T100MD+

More information

Chapter_06

Chapter_06 프로그래밍 1 1 Chapter 6. Functions and Program Structure April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj 이장의강의목표 2 문자의입력방법을이해한다. 중첩된 if문을이해한다. while 반복문의사용법을익힌다. do 반복문의사용법을익힌다.

More information

Infinity(∞) Strategy

Infinity(∞) Strategy 반복제어 표월성 passwd74@cherub.sungkyul.edu 개요 for() 문 break문과 continue문 while문 do-while문 for() 문 for() 문형식 for( 표현식1; 표현식2; 표현식3) 여러문장들 ; 표현식 1 : 초기화 (1 번만수행 ) 표현식 2 : 반복문수행조건 ( 없으면무한반복 ) 표현식 3 : 반복문수행횟수 for()

More information

Chap 6: Graphs

Chap 6: Graphs AOV Network 의표현 임의의 vertex 가 predecessor 를갖는지조사 각 vertex 에대해 immediate predecessor 의수를나타내는 count field 저장 Vertex 와그에부속된모든 edge 들을삭제 AOV network 을인접리스트로표현 count link struct node { int vertex; struct node

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

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx

Microsoft PowerPoint - 알고리즘_5주차_1차시.pptx Basic Idea of External Sorting run 1 run 2 run 3 run 4 run 5 run 6 750 records 750 records 750 records 750 records 750 records 750 records run 1 run 2 run 3 1500 records 1500 records 1500 records run 1

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

사용자수준의스레드 : 사용자의라이브러리에의해운영, 속도는빠르나, 구현이복잡하다. 커널수준의스레드 : 운영체제커널에의해운영, 속도는느리나, 구현이단순하다. 스케줄링 (Scheduling) 1) 스케줄링의정의 프로세스가생성되어실행될때필요한시스템의여러자원을해당프로세스에게할당

사용자수준의스레드 : 사용자의라이브러리에의해운영, 속도는빠르나, 구현이복잡하다. 커널수준의스레드 : 운영체제커널에의해운영, 속도는느리나, 구현이단순하다. 스케줄링 (Scheduling) 1) 스케줄링의정의 프로세스가생성되어실행될때필요한시스템의여러자원을해당프로세스에게할당 프로세스 (Process) 1) 프로세스의개념 프로세서에의해처리되어지는사용자프로그램및시스템프로그램을의미한다. 현재실행중인프로그램이며 Job(=Task) 이라고도한다. PCB를가지는프로그램으로비동기적인행위를일으키는주체이며실제주기억장치에저장된프로그램이다. 운영체제가관리하는실행단위이며프로시저 ( 프로그램내의하위프로그램 ) 가활동중인것을의미한다. 2) 프로세스의상태전이과정

More information

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V Mobile Service > IAP > Android SDK IAP SDK TOAST SDK. IAP SDK. Android Studio IDE 2.3.3 Android SDK Version 2.3.3 (API Level 10). Name Reference Version License okhttp http://square.github.io/okhttp/ 1.5.4

More information

0.1-6

0.1-6 HP-19037 1 EMP400 2 3 POWER EMP400 4 5 6 7 ALARM CN2 8 9 CN3 CN1 10 24V DC CN4 TB1 11 12 Copyright ORIENTAL MOTOR CO., LTD. 2001 2 1 2 3 4 5 1.1...1-2 1.2... 1-2 2.1... 2-2 2.2... 2-4 3.1... 3-2 3.2...

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

RVC Robot Vaccum Cleaner

RVC Robot Vaccum Cleaner RVC Robot Vacuum 200810048 정재근 200811445 이성현 200811414 김연준 200812423 김준식 Statement of purpose Robot Vacuum (RVC) - An RVC automatically cleans and mops household surface. - It goes straight forward while

More information

Interstage4 설치가이드

Interstage4 설치가이드 Interstage Application Server V501 Operation Guide Internet 1 1 1 FJApache FJApache (WWW (WWW server) server) - - file file - - 2 2 InfoProviderPro InfoProviderPro (WWW (WWW server) server) - - file file

More information

( )부록

( )부록 A ppendix 1 2010 5 21 SDK 2.2. 2.1 SDK. DevGuide SDK. 2.2 Frozen Yoghurt Froyo. Donut, Cupcake, Eclair 1. Froyo (Ginger Bread) 2010. Froyo Eclair 0.1.. 2.2. UI,... 2.2. PC 850 CPU Froyo......... 2. 2.1.

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

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

/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

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE ALTIBASE HDB 6.3.1.10.1 Patch Notes 목차 BUG-45710 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG-45730 ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG-45760 ROLLUP/CUBE 절을포함하는질의는 SUBQUERY REMOVAL 변환을수행하지않도록수정합니다....

More information

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600 균형이진탐색트리 -VL Tree delson, Velskii, Landis에의해 1962년에제안됨 VL trees are balanced n VL Tree is a binary search tree such that for every internal node v of T, the heights of the children of v can differ by at

More information

chap x: G입력

chap x: G입력 재귀알고리즘 (Recursive Algorithms) 재귀알고리즘의특징 문제자체가재귀적일경우적합 ( 예 : 피보나치수열 ) 이해하기가용이하나, 비효율적일수있음 재귀알고리즘을작성하는방법 재귀호출을종료하는경계조건을설정 각단계마다경계조건에접근하도록알고리즘의재귀호출 재귀알고리즘의두가지예 이진검색 순열 (Permutations) 1 장. 기본개념 (Page 19) 이진검색의재귀알고리즘

More information

PRO1_09E [읽기 전용]

PRO1_09E [읽기 전용] Siemens AG 1999 All rights reserved File: PRO1_09E1 Information and - ( ) 2 3 4 5 Monitor/Modify Variables" 6 7 8 9 10 11 CPU 12 Stop 13 (Forcing) 14 (1) 15 (2) 16 : 17 : Stop 18 : 19 : (Forcing) 20 :

More information

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Crash Unity SDK... Log & Crash Search. - Unity3D v4.0 ios

More information

윈도우즈프로그래밍(1)

윈도우즈프로그래밍(1) 제어문 (2) For~Next 문 윈도우즈프로그래밍 (1) ( 신흥대학교컴퓨터정보계열 ) 2/17 Contents 학습목표 프로그램에서주어진특정문장을부분을일정횟수만큼반복해서실행하는문장으로 For~Next 문등의구조를이해하고활용할수있다. 내용 For~Next 문 다중 For 문 3/17 제어문 - FOR 문 반복문 : 프로그램에서주어진특정문장들을일정한횟수만큼반복해서실행하는문장

More information

예제 1.1 ( 관계연산자 ) >> A=1:9, B=9-A A = B = >> tf = A>4 % 4 보다큰 A 의원소들을찾을경우 tf = >> tf = (A==B) % A

예제 1.1 ( 관계연산자 ) >> A=1:9, B=9-A A = B = >> tf = A>4 % 4 보다큰 A 의원소들을찾을경우 tf = >> tf = (A==B) % A 예제 1.1 ( 관계연산자 ) >> A=1:9, B=9-A A = 1 2 3 4 5 6 7 8 9 B = 8 7 6 5 4 3 2 1 0 >> tf = A>4 % 4 보다큰 A 의원소들을찾을경우 tf = 0 0 0 0 1 1 1 1 1 >> tf = (A==B) % A 의원소와 B 의원소가똑같은경우를찾을때 tf = 0 0 0 0 0 0 0 0 0 >> tf

More information

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout <<  양수입력 : ; cin >> *p; if (*p <= 0) cout <<  양수를입력해야합니다  << endl; return; 동적할 15 장기타주제들 auto_ptr 변환함수 cast 연산자에의한명시적형변환실행시간타입정보알아내기 (RTTI) C++ 프로그래밍입문 1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout > *p; if (*p

More information

Microsoft PowerPoint os2.ppt [호환 모드]

Microsoft PowerPoint os2.ppt [호환 모드] 2 장컴퓨터시스템구조 (Computer-System Structures) 컴퓨터시스템연산 (Computer System Operation) 입출력구조 (I/O Structure) 저장장치구조 (Storage Structure) 저장장치계층 (Storage Hierarchy) 하드웨어보호 (Hardware Protection) 일반적인시스템구조 (General

More information

좀비프로세스 2

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

More information

untitled

untitled Memory leak Resource 力 金 3-tier 見 Out of Memory( 不 ) Memory leak( 漏 ) 狀 Application Server Crash 理 Server 狀 Crash 類 JVM 說 例 行說 說 Memory leak Resource Out of Memory Memory leak Out of Memory 不論 Java heap

More information

ETL_project_best_practice1.ppt

ETL_project_best_practice1.ppt ETL ETL Data,., Data Warehouse DataData Warehouse ETL tool/system: ETL, ETL Process Data Warehouse Platform Database, Access Method Data Source Data Operational Data Near Real-Time Data Modeling Refresh/Replication

More information

슬라이드 1

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

More information

untitled

untitled 9 hamks@dongguk.ac.kr : Source code Assembly language code x = a + b; ld a, %r1 ld b, %r2 add %r1, %r2, %r3 st %r3, x (Assembler) (bit pattern) (machine code) CPU security (code generator).. (Instruction

More information

일반적인 네트워크의 구성은 다음과 같다

일반적인 네트워크의 구성은 다음과 같다 W5200 Errata Sheet Document History Ver 1.0.0 (Feb. 23, 2012) First release (erratum 1) Ver 1.0.1 (Mar. 28, 2012) Add a solution for erratum 1, 2 Ver 1.0.2 (Apr. 03, 2012) Add a solution for erratum 3

More information

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

Microsoft PowerPoint - 30.ppt [호환 모드] 이중포트메모리의실제적인고장을고려한 Programmable Memory BIST 2010. 06. 29. 연세대학교전기전자공학과박영규, 박재석, 한태우, 강성호 hipyk@soc.yonsei.ac.kr Contents Introduction Proposed Programmable Memory BIST(PMBIST) Algorithm Instruction PMBIST

More information

Windows Embedded Compact 2013 [그림 1]은 Windows CE 로 알려진 Microsoft의 Windows Embedded Compact OS의 history를 보여주고 있다. [표 1] 은 각 Windows CE 버전들의 주요 특징들을 담고

Windows Embedded Compact 2013 [그림 1]은 Windows CE 로 알려진 Microsoft의 Windows Embedded Compact OS의 history를 보여주고 있다. [표 1] 은 각 Windows CE 버전들의 주요 특징들을 담고 OT S / SOFTWARE 임베디드 시스템에 최적화된 Windows Embedded Compact 2013 MDS테크놀로지 / ES사업부 SE팀 김재형 부장 / jaei@mdstec.com 또 다른 산업혁명이 도래한 시점에 아직도 자신을 떳떳이 드러내지 못하고 있는 Windows Embedded Compact를 오랫동안 지켜보면서, 필자는 여기서 그와 관련된

More information

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

목차 BUG DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4

목차 BUG DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4 ALTIBASE HDB 6.5.1.5.10 Patch Notes 목차 BUG-46183 DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG-46249 [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4 BUG-46266 [sm]

More information

Chap7.PDF

Chap7.PDF Chapter 7 The SUN Intranet Data Warehouse: Architecture and Tools All rights reserved 1 Intranet Data Warehouse : Distributed Networking Computing Peer-to-peer Peer-to-peer:,. C/S Microsoft ActiveX DCOM(Distributed

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

슬라이드 1

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

More information

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2 학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2 6.1 함수프로시저 6.2 서브프로시저 6.3 매개변수의전달방식 6.4 함수를이용한프로그래밍 3 프로시저 (Procedure) 프로시저 (Procedure) 란무엇인가? 논리적으로묶여있는하나의처리단위 내장프로시저 이벤트프로시저, 속성프로시저, 메서드, 비주얼베이직내장함수등

More information

歯처리.PDF

歯처리.PDF E06 (Exception) 1 (Report) : { $I- } { I/O } Assign(InFile, InputName); Reset(InFile); { $I+ } { I/O } if IOResult 0 then { }; (Exception) 2 2 (Settling State) Post OnValidate BeforePost Post Settling

More information

9

9 9 hamks@dongguk.ac.kr : Source code Assembly language code x = a + b; ld a, %r1 ld b, %r2 add %r1, %r2, %r3 st %r3, x (Assembler) (bit pattern) (machine code) CPU security (code generator).. (Instruction

More information