Mutex, Semaphore, Critical Section 동기화 메커니즘 성능 비교
멀티스레드 프로그래밍에서 Mutex, Semaphore, 그리고 Critical Section은 동기화 메커니즘의 대표적인 예입니다. 이 글에서는 각 메커니즘의 성능 차이를 C++ 프로그램을 통해 비교하고, 동시에 프로그램의 진행 상태를 확인할 수 있도록 진행 바(progress bar)를 추가하는 방법을 설명합니다.1. C++ 코드: Mutex, Semaphore, Critical Section 비교아래 코드는 Mutex, Semaphore, Critical Section을 각각 사용하여 공유 자원에 접근하고, 성능을 비교하는 예제입니다. 또한 프로그램의 진행 상태를 실시간으로 관찰할 수 있도록 1%마다 진행 바를 출력하도록 하였습니다.// C++ 코드#include #include #include #..
timespan, ctime 사용법 C/C++ MFC
if (m_SelectedTime_Start < m_SelectedTime_End) { CTime tCurTime( m_SelectedTime_Start.GetYear(), m_SelectedTime_Start.GetMonth(), m_SelectedTime_Start.GetDay(), 0, 0, 0, 0); for (int i = 0; i < Search_term; i++) { temp_date[i].Format(_T("result_%04d_%02d_%02d"), tCurTime.GetYear(), tCurTime.GetMonth(), tCurTime.GetDay()); tCurTime += CTimeSpan(1, 0, 0, 0); } }