성적공시

학번 출석 (20%) H

W

0

H

W

1

H

W

2

H

W

3

H

W

4

H

W

5

중간고사 H

W

6

H

W

7

개별 숙제 (30%) 개별발표 개별 발표 (30%) 기말발표 기말 발표 (20%) TOTAL
52101800 20.00 9 10 9 10 5 8 3 5 0 19.67 10 30.00 10 20.00 89.67
52111760 17.33 0 0 0 10 0 0 0 0 0 3.33 6 18.00 8 16.00 54.67
52111765 19.33 10 10 10 10 5 10 10 8 10 27.67 10 30.00 10 20.00 97.00
52111781 18.33 0 0 8 11 0 0 1 0 0 6.67 7 21.00 0 0.00 46.00
52101834 20.00 10 9 10 10 0 8 0 0 0 15.67 7 21.00 7 14.00 70.67
52111792 20.00 10 10 10 10 10 8 3 5 1 22.33 10 30.00 9 18.00 90.33
52101841 14.67 0 0 0 0 0 0 0 0 0 0.00 0 0.00 0 0.00 14.67

Java Monitor

Java Monitor (classic reader-writer problem) 1 writer & 2 readers

JavaMultithreadMonitor

 

The writer fills data until the buffer is full. If the buffer is full (condition variable), then waits. Otherwise (i.e., the buffer is available), it fills data in the buffer. After that, it signals.

The reader reads data until the buffer is empty. If the buffer is empty (condition variable), then wait. Otherwise (i.e., the buffer is available), it reads data. After that, it signals.

Shared Memory & Semaphore

NOTE: BinarySemaphore is the same as Mutex (for one shared resource).

1. SharedMemoryBinarySemaphoreWriter & SharedMemoryBinarySemaphoreReader
First, run SharedMemoryBinarySemaphoreWriter.exe (this only writes data on the shared memory segment.)

SharedMemoryBinarySemaphoreWriter

Then, run SharedMemoryBinarySemaphoreReader.exe (it only reads data from the shared memory segment.)

SharedMemoryBinarySemaphoreReader

2. SharedMemoryBinarySemaphoreMasterSlave (Both master/slaves write/reads data to/from the shared memory segment.)
First, run SharedMemoryBinarySemaphoreMasterSlave.exe –master
Then, run SharedMemoryBinarySemaphoreMasterSlave.exe

SharedMemoryBinarySemaphoreMasterSlave

 

NOTE: Semaphore allows a specific number of processes/threads to enter.

3. SharedMemoryGeneralSemaphoreMasterSlave (classic reader-writer problem)

The writer fills data until the buffer is full. It waits emptyBufferSemaphore (e–) to be available. If so, it fills data. After that, it signals fullBufferSemaphore(f++) ready.

The reader reads data until the buffer is empty. It waits fullBufferSemaphore(f–) to be available. If so, it reads data. After that, it signals emptyBufferSemaphore(e++) to be ready.

1 master is the writer (fills data the shared memory buffer).

2 slaves are the readers (read data from the shared memory buffer; but their reader index must be synchronized).
First, run SharedMemoryGeneralSemaphoreMasterSlave.exe –master
Next, run SharedMemoryGeneralSemaphoreMasterSlave.exe
Then, run SharedMemoryGeneralSemaphoreMasterSlave.exe

SharedMemoryGeneralSemaphoreMasterSlave

 

Shared Memory & Mutex

1. SharedMemoryMutexWriter & SharedMemoryMutexReader
First, run SharedMemoryMutexWriter.exe (this only writes data on the shared memory segment.)
SharedMemoryMutexWriter

Then, run SharedMemoryMutexReader.exe (it only reads data from the shared memory segment.)
SharedMemoryMutexReader

2. SharedMemoryMutexMasterSlave (Both master/slaves write/reads data to/from the shared memory segment.)
First, run SharedMemoryMutexMasterSlave.exe –master
Then, run SharedMemoryMutexMasterSlave.exe
SharedMemoryMutexMasterSlave

Microsoft C++ Synchronization Object

Microsoft C++ Synchronization Object (동기화객체)

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686364(v=vs.85).aspx

http://thermidor.tistory.com/23

 

Critical Section
(뮤텍스와 비슷하나, 동일 프로세서 내에서만 사용 가능하다.)

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682530(v=vs.85).aspx

-InitializeCriticalSection // 초기화

-DeleteCriticalSection // 삭제

-EnterCriticalSection // lock

-LeaveCriticalSectgion // unlock

 

Mutex
(뮤텍스 객체를 생성하여 사용하므로 Critical Section에 비해서 느리다. 최초에 Signaled 상태로 생성되어지며, WaitForSingleObject 대기함수를 호출함으로써 NonSignaled 상태가 된다. Critical Section 객체의 경우 다른 스레드에 의해 소유되면 EnterCriticalSection은 무한정 기다리게되는 반면-즉, 데드락이 가능- 뮤텍스 객체는 WaitForSingleObject를 사용하여 타임아웃이 가능하다.)

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684266(v=vs.85).aspx

-CreateMutuex // 뮤텍스 생성 (전역으로 하나만 생성)

-OpenMutex // 뮤텍스 열기

-ReleaseMutex // 뮤텍스 소유 해제

-CloseHandle // 뮤텍스 파괴

-WaitForSingleObject // 동기화 대기

-WaitForMultipleObject // 여러 개의 동기화 객체 대기

 

Semaphore
(뮤텍스가 하나의 shared resource을 lock/unlock하는데 비해, 세마포어는 일정 개수를 가지는 자원을 lock/unlock할 수 있다. )

https://msdn.microsoft.com/en-us/library/windows/desktop/ms685129(v=vs.85).aspx

-CreateSemaphore // 세마포어 생성 (최대 사용개수 지정)

-OpenSemaphore // 세마포어 열기

-ReleaseSemaphore // 세마포어 소유 해제

 

Event
(Critical Section, Mutex, Semaphore가 공유자원 lock/unlock에 사용하는데 비해, 이벤트는 스레드의 작업순서나 시기를 조정하기 위해 사용된다.)

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682655(v=vs.85).aspx

-CreateEvent // 이벤트 생성

-OpenEvent // 이벤트 열기

-SetEvent // 사용자 임의로 신호상태와 비신호상태를 설정가능

-ResetEvent // 이벤트 리셋