'분류 전체보기'에 해당되는 글 45건

  1. 2010.12.10 자체 스핀락 이용
  2. 2010.12.10 Concurrency
  3. 2010.12.10 식사하는 철학자
  4. 2010.12.10 Mutex
  5. 2010.12.10 Semaphore
  6. 2010.12.10 CriticalSection
  7. 2010.12.10 SpinLock
  8. 2010.12.10 SpinLock2
  9. 2010.12.10 SimpleConcurrency
  10. 2010.12.10 HandleBased Operation System
posted by Kyleslab 2010. 12. 10. 22:08


// Test.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

#include "Concurrency/Thread.h"
#include "Concurrency/SpinLock.h"

//이거 연결은 정적 라이브러리 연결 동적이 나올수도 있음

string g_buffer;
SpinLock g_lock; //1000번 찍는데 락을 걸어주기 위해서 우리가 만든 락 클래스를 이용한다.

int _tmain(int argc, _TCHAR* argv[])
{
 vector<Thread * >threads; //힙을 이용하면 new를 이용하면 생성하고 delete를 하면 우리가 생성 소멸 타이밍을 조절 할 수 있다.

 for(int i =0; i < 5; ++i)
 {
  char ch = 'a'+i;
  threads.push_back(new Thread( // 푸시백은 백터 맨뒤에 이것들을 추가하는것
  [ ch ]()->void //[]여기 안에는 클로져 특성을 가지는 변수, 캡쳐할 리스트들 ()인자값이 들어감
  {
   g_lock.lock();
   for(int i =0; i < 1000; ++i)
   {
    g_buffer +=ch;
   }
   g_lock.unlock(); //락을 걸어준다.

  }));
 }
 for_each(threads.begin(), //이것은 외우기
  threads.end(),
  [](Thread * thread)  //포위치로 쓰래드를 처음부터 끝까지 훌터서 지울려고 하는거임
 {
  delete thread; //벡터에는 포인터가 들어있기 때문에 벡터의 원소는 변화가 없다. 쓰레드가 종료 되면 지워버림
 });
   
 cout<<g_buffer<<endl;
 return 0;
}

 

'Operations Dev > Concurrency' 카테고리의 다른 글

자체 뮤텍스락 이용  (0) 2010.12.10
Concurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 22:07

-----Thread.h
#pragma once

#include <functional>

//Rari? 리소스를 얻으면 바로 초기화한다.보통 윈도 api를 사용한다. 독립적으로 되려면 매기기 마다 컴파일해야한다. ios로 가면 ios api를 써야한다.

class Thread
{
public:
 Thread( std::function< void () > const & threadFunc );//스레드를 만들 함수를 넘기다. 리턴타입없고 인자도없다.
 ~Thread();

public:
 unsigned int
  getThreadId() const;
 unsigned int
  getThreadHandle() const;

private:
 Thread( Thread const & value ){}
 Thread & operator=( Thread const & value){ return *this;}

private:
 unsigned int _threadId;
 unsigned int _threadHandle;
 std::function< void () > _threadFunc; // 터지는 것을 방지 하고 위해서 쓰레드의 생명주기를 클래스와 같게 한다.

};

---Thread.cpp
//#ifdef _WIN32 //플랫폼 독립적인 녀석을 만들때

#include "stdafx.h"

#include "Thread.h"

#include <Windows.h>
#include <process.h>

static unsigned int __stdcall ThreadEntryPoint ( void * arg ) // static외부에서 절대 접근불가함수 이파일안에서만 동작 윈도우 스레드로 만들어져서 넘길수있다.
{
 (* ( std::function< void () >* )( arg ))();

 return 0;

}


Thread::Thread( std::function< void () > const & threadFunc )
 :_threadFunc( threadFunc )
{
 //우리가 만들고 싶은 것은 threadFunc 스레드인데 비긴스레드는 불가능 하다. 스레드엔트리포인트는 비긴스레드가 가능하니까 스레드펀크함수를 변수로 해서 전달한다.
 _threadHandle = ::_beginthreadex( NULL, 
      0,
      ThreadEntryPoint,
      ( void *)( &_threadFunc ), // 없어진것을 호출하면 터진다.
      0,
      &_threadId);
}

Thread::~Thread()
{
 ::WaitForSingleObject( ( HANDLE )( _threadHandle ), INFINITE); //반드시해주어야함 모든 자식 스레드를 종료해주기 위해 메인스레드가 종료하면 소멸자를 호출하게 되고 자신의 핸들스레드가 종료될때까지 기다리게 한다.!!!
 ::CloseHandle( ( HANDLE )( _threadHandle ) ); // 그다음에 메인 스레드를 종료한다.
}

unsigned int
 Thread::getThreadId() const
{
 return _threadId;
}

unsigned int
 Thread::getThreadHandle() const
{
 return _threadHandle;
}

---SpinLock.h
#pragma once

#include <Windows.h>
class SpinLock
{
public:
 SpinLock();
 ~SpinLock();

public:
 void lock();
 void unlock();

private:
 SpinLock(SpinLock const & value){}
 SpinLock &operator = (SpinLock const & rhs){return * this;}

private:
 ::CRITICAL_SECTION _lock;
};

-- SpinLock.cpp
#include "stdafx.h"

#include "SpinLock.h"

SpinLock::SpinLock()
{
 ::InitializeCriticalSection(&_lock); //객체 생성
}

SpinLock::~SpinLock()
{
 ::DeleteCriticalSection(&_lock); //해제
}

void SpinLock::lock()
{
 ::EnterCriticalSection(&_lock);
}

void SpinLock::unlock()
{
 ::LeaveCriticalSection(&_lock);
}

--Mutex.h
#pragma once

#include <Windows.h>
class MutexLock
{
public:
 MutexLock();
 ~MutexLock();

public:
 void lock();
 void unlock();

private:
 MutexLock(MutexLock const & value){}
 MutexLock &operator = (MutexLock const & rhs){return * this;}

private:
 HANDLE _lock;
};

--Mutex.cpp
#include "stdafx.h"

#include "MutexLock.h"

MutexLock::MutexLock()
{
  _lock = ::CreateMutexA(NULL, FALSE, NULL);//객체 생성
}

MutexLock::~MutexLock()
{
  ::CloseHandle(_lock); //해제
}

void MutexLock::lock()
{
 ::WaitForSingleObject(_lock, INFINITE);
}

void MutexLock::unlock()
{
 ::ReleaseMutex(_lock);
}

'Operations Dev > Concurrency' 카테고리의 다른 글

자체 뮤텍스락 이용  (0) 2010.12.10
자체 스핀락 이용  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 21:22

// Chapter06.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <string>

#include <windows.h>
#include <process.h>

#include <iostream>
using namespace std;

int const MAX_FORK = 5;
int const MAX_PHILOSOPHER = 5;
HANDLE g_forks[ MAX_FORK ];
HANDLE g_room;


void eat( string const & philosopher );
void think( string const & philosopher );
unsigned int WINAPI startDinner( LPVOID param );

int _tmain(int argc, _TCHAR* argv[])
{
 string philo[MAX_PHILOSOPHER] = {"Socrates", "Plato", "Fredeu", "Kant", "Kongja"};
 DWORD threadIDs[MAX_PHILOSOPHER];
 HANDLE threadHandles[ MAX_PHILOSOPHER ];

 for( int i = 0; i < MAX_FORK; ++i )
 {

  g_forks[ i ] = ::CreateSemaphore( NULL, 1, 1, NULL );

 }
 g_room = ::CreateSemaphore( NULL, 4, 4, NULL );

 for(int i =0; i<MAX_PHILOSOPHER; ++i)
 {
  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , startDinner,(LPVOID*)(&philo[i]),0,(unsigned int *)&threadIDs[i]);
 }

 DWORD result = ::WaitForMultipleObjects(MAX_PHILOSOPHER, &threadHandles[0],TRUE,INFINITE);
 if(result == WAIT_OBJECT_0)
 {

 }

 for( int i = 0; i < MAX_FORK; ++i )
 {

  ::ReleaseSemaphore(g_forks[i],1,NULL);

 }
 ::ReleaseSemaphore(g_room,1,NULL);


 for(int i = 0; i< MAX_PHILOSOPHER; ++i)
 {
  CloseHandle(threadHandles[i]);
  CloseHandle(g_forks[i]);
 }
 CloseHandle(g_room);


 return 0;
}


void eat( string const & philosopher )
{

 ::Sleep( 100 );
 cout << philosopher+" eat something.\n";
 //printf("%s eat something.\n",philosopher);
}

void think( string const & philosopher )
{

 ::Sleep( 100 );
 cout << philosopher+" think something.\n";
 //printf("%s think something.\n",philosopher);

}

unsigned int WINAPI startDinner( LPVOID param )
{
 string ch = *((string *)param);
 for(int i =0 ; i< MAX_FORK ; i++)
 {

  think(ch);
  DWORD result = ::WaitForSingleObject(g_room,INFINITE);
  DWORD result2 = ::WaitForSingleObject(g_forks[i],INFINITE);
  result2 = ::WaitForSingleObject(g_forks[i+1%5],INFINITE);

  eat(ch);
  ::ReleaseSemaphore(g_forks[i+1%5],1,NULL);
  ::ReleaseSemaphore(g_forks[i],1,NULL);
  ::ReleaseSemaphore(g_room,1,NULL);
 }

 return 0;
}

posted by Kyleslab 2010. 12. 10. 18:24


// Example02_Mutex.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include "Windows.h"
#include <process.h>

//#include <concrt.h>

#include <string>
#include <iostream>
using namespace std;

unsigned int WINAPI writeCharacter( LPVOID param);

string g_string;
int const MAX_THREAD = 5;
HANDLE g_mutexHandle;

int _tmain(int argc, _TCHAR* argv[])
{
 //가용 공간을 미리 예약해 놓는 부분,
 //g_string.reserve( MAX_THREAD * 1000 +1 );

 g_mutexHandle = ::CreateMutexA( NULL, FALSE, NULL);

 //char ch = 'a';
 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i=0; i < MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;
  threadHandles[i] = (HANDLE)::_beginthreadex( NULL,
   0,
   writeCharacter,
   (LPVOID*)(&alphas[i]), // LPVOID 포인터 타입 무슨 타입인지알아야한다. 이것은 char타입니다.
   0,
   (unsigned int *)&threadIDs[i]);

 }

 DWORD result =
  ::WaitForMultipleObjects(MAX_THREAD,
  &threadHandles[0],
  TRUE,
  INFINITE);

 //결과값이 제대로 나온다면
 if(result == WAIT_OBJECT_0)
 {
  cout<<g_string;
 }

 //::ReleaseMutex(g_mutexHandle);

 for(int i=0; i < MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }
 CloseHandle( g_mutexHandle);
 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char*)param);

 DWORD result = ::WaitForSingleObject(g_mutexHandle,INFINITE); // 대기시간 무한!

 for(int i = 0; i < 1000; ++i)
 {
  g_string += ch;
 }

 ::ReleaseMutex(g_mutexHandle);

 return 0;
}

'Operations Dev > writech' 카테고리의 다른 글

Semaphore  (0) 2010.12.10
CriticalSection  (0) 2010.12.10
SpinLock  (0) 2010.12.10
SpinLock2  (0) 2010.12.10
SimpleConcurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 18:23

// Example03_Semaphore.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include<windows.h>
#include<process.h>

#include<string>
#include<iostream>
using namespace std;

unsigned int WINAPI writeCharacter(LPVOID param);

string g_string;
int const MAX_THREAD = 5;
HANDLE g_semaphoreHandle;

int _tmain(int argc, _TCHAR* argv[])
{
 g_semaphoreHandle = ::CreateSemaphore(NULL,1, 1 , NULL);
 g_string.reserve(MAX_THREAD * 1000 +1);  //가용공간 예약부분

 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i =0; i<MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;

  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , writeCharacter,(LPVOID*)(&alphas[i]),0,(unsigned int *)&threadIDs[i]);
 }
 
 DWORD result = ::WaitForMultipleObjects(MAX_THREAD, &threadHandles[0],TRUE,INFINITE);
 if(result == WAIT_OBJECT_0)
 {
  
  cout<<g_string;
  
 }

 for(int i = 0; i< MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }
 CloseHandle(g_semaphoreHandle);

 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char *)param);
 DWORD result = ::WaitForSingleObject(g_semaphoreHandle,INFINITE);
 for(int i = 0; i< 1000; ++i)
 {
  g_string += ch;
 }
 ::ReleaseSemaphore(g_semaphoreHandle,1,NULL);
 
 return 0;
}


 

'Operations Dev > writech' 카테고리의 다른 글

Mutex  (0) 2010.12.10
CriticalSection  (0) 2010.12.10
SpinLock  (0) 2010.12.10
SpinLock2  (0) 2010.12.10
SimpleConcurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 18:22

// Example04_CriticalSection.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
// CriticalSection은 유저모드(재귀 스핀락)인데 오늘은 일반 락

#include "stdafx.h"

#include<windows.h>
#include<process.h>

#include<string>
#include<iostream>
using namespace std;

unsigned int WINAPI writeCharacter(LPVOID param);

string g_string;
int const MAX_THREAD = 5;
CRITICAL_SECTION  g_criticalSection;

int _tmain(int argc, _TCHAR* argv[])
{
 ::InitializeCriticalSection(&g_criticalSection);

 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i =0; i<MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;

  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , writeCharacter,(LPVOID*)(&alphas[i]),0,(unsigned int *)&threadIDs[i]);
 }
 
 DWORD result = ::WaitForMultipleObjects(MAX_THREAD, &threadHandles[0],TRUE,INFINITE);
 if(result == WAIT_OBJECT_0)
 {
  
  cout<<g_string;
  
 }
 for(int i = 0; i< MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }
 ::DeleteCriticalSection(&g_criticalSection);

 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char *)param);
 ::EnterCriticalSection(&g_criticalSection);
 /***************임계영역 *************************/
 for(int i = 0; i< 1000; ++i)
 {
  g_string += ch;
 }
 /**************************************************/
 ::LeaveCriticalSection(&g_criticalSection);
 
 return 0;
}

'Operations Dev > writech' 카테고리의 다른 글

Mutex  (0) 2010.12.10
Semaphore  (0) 2010.12.10
SpinLock  (0) 2010.12.10
SpinLock2  (0) 2010.12.10
SimpleConcurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 18:22


// Example05_SpinLock.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
// 커널모르게 돌리면 유저모드

#include "stdafx.h"

#include<windows.h>
#include<process.h>

#include<string>
#include<iostream>
using namespace std;

unsigned int WINAPI writeCharacter(LPVOID param);

string g_string;
int const MAX_THREAD = 5;
bool g_isLocked = false;

int _tmain(int argc, _TCHAR* argv[])
{
 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i =0; i<MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;

  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , writeCharacter,(LPVOID*)(&alphas[i]),0,(unsigned int *)&threadIDs[i]);
 }
 
 DWORD result = ::WaitForMultipleObjects(MAX_THREAD, &threadHandles[0],TRUE,INFINITE);
 if(result == WAIT_OBJECT_0)
 {
  
  cout<<g_string;
  
 }
 for(int i = 0; i< MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }

 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char *)param);
 
 while(g_isLocked); 
 g_isLocked = true;   //이곳에서 ContextSwitching이 일어나면 위의 while문에서 뻑날수있다. 원자적연산이 아니기때문에.
 /***************임계영역 *************************/
 for(int i = 0; i< 1000; ++i)
 {
  g_string += ch;
 }
 /**************************************************/
 g_isLocked = false;
 
 
 return 0;
}

'Operations Dev > writech' 카테고리의 다른 글

Mutex  (0) 2010.12.10
Semaphore  (0) 2010.12.10
CriticalSection  (0) 2010.12.10
SpinLock2  (0) 2010.12.10
SimpleConcurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 18:10

// Example06_SpinLock2.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"

#include<windows.h>
#include<process.h>

#include<string>
#include<iostream>
using namespace std;

unsigned int WINAPI writeCharacter(LPVOID param);

string g_string;
int const MAX_THREAD = 5;
long g_key =1;

int _tmain(int argc, _TCHAR* argv[])
{
 

 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i =0; i<MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;

  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , writeCharacter,(LPVOID*)(&alphas[i]),0,(unsigned int *)&threadIDs[i]);
 }
 
 DWORD result = ::WaitForMultipleObjects(MAX_THREAD, &threadHandles[0],TRUE,INFINITE);
 if(result == WAIT_OBJECT_0)
 {
  
  cout<<g_string;
  
 }
 for(int i = 0; i< MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }

 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char *)param);
 
 LONG key = g_key;
 while(1 != ::InterlockedCompareExchange(&g_key, 0 ,1));  //( 조건 ? 참 : 거짓)과 같다
 /***************임계영역 *************************/
 for(int i = 0; i< 1000; ++i)
 {
  g_string += ch;
 }
 /**************************************************/
 g_key = 1; 
 
 return 0;
}

 

'Operations Dev > writech' 카테고리의 다른 글

Mutex  (0) 2010.12.10
Semaphore  (0) 2010.12.10
CriticalSection  (0) 2010.12.10
SpinLock  (0) 2010.12.10
SimpleConcurrency  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 17:53

// Example01_Simple.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include<windows.h>
#include<process.h>

#include<string>
#include<iostream>
using namespace std;

unsigned int WINAPI writeCharacter(LPVOID param);

string g_string;
int const MAX_THREAD = 5;

int _tmain(int argc, _TCHAR* argv[])
{
 g_string.reserve(MAX_THREAD * 1000 +1);  //가용공간 예약부분

 //char ch = 'a' ;
 DWORD threadIDs[MAX_THREAD];
 HANDLE threadHandles[MAX_THREAD];
 char alphas[MAX_THREAD];

 for(int i =0; i<MAX_THREAD; ++i)
 {
  alphas[i] = 'a' + i;

  threadHandles[i] = (HANDLE) ::_beginthreadex( NULL, 0 , writeCharacter,(LPVOID*)(&alphas[i]),0,(unsigned int *)&threadIDs[i]);
 }
 
 DWORD result =
  ::WaitForMultipleObjects(MAX_THREAD, &threadHandles[0],TRUE,INFINITE); //블록상태로 전환시킨다. 이 커널Object가 사용가능할 때까지
                 //대기시간 무한
 if(result == WAIT_OBJECT_0)  //대기가 끝난후 결과가 나오면 출력
 {
  cout<<g_string;
 }
 for(int i = 0; i< MAX_THREAD; ++i)
 {
  CloseHandle(threadHandles[i]);
 }

 return 0;
}

unsigned int WINAPI writeCharacter(LPVOID param)
{
 char ch = *((char *)param);
 for(int i = 0; i< 1000; ++i)
 {
  g_string += ch;
 }
 
 return 0;
}

'Operations Dev > writech' 카테고리의 다른 글

Mutex  (0) 2010.12.10
Semaphore  (0) 2010.12.10
CriticalSection  (0) 2010.12.10
SpinLock  (0) 2010.12.10
SpinLock2  (0) 2010.12.10
posted by Kyleslab 2010. 12. 10. 17:43

-- Process.h
#pragma once

#include <string>

class Process
{
public:
 Process(std::string const & name);

public:
 void excute(std::string const & message);//const 변경하지말라! &빠르게 넘기겠다!

private:
 std::string _name;
};

-- Process.cpp
#include "stdafx.h"

#include <iostream>
using namespace std;

#include "Process.h"
Process::Process( std::string const & name)
 : _name( name )
{
}

void Process::excute(const std::string & message)//const 변경하지말라! &빠르게 넘기겠다!
{
 cout<<_name<<"executed"<<message<<endl;
}

--Operation System.h
#pragma once

#include <map>
#include <string>

class Process;

class OperatingSystem
{

public:
 OperatingSystem();
 ~OperatingSystem();
public:
 int createProcess(std::string const & processName);
 void sendMessage(int processHandle, std::string const & message);
public:
 void getHandle (std::string const & processName);
private:
 std::map<int, Process *> _table;
 std::map<std::string, int> _handeltable;

private:
 static int _HandleCouter;// 클래스안에서 하나만 생성된다 인스턴스를 아무리 많이 만들어도
};

--Operation.cpp
#include "stdafx.h"
#include "Process.h"
#include "OperatingSystem.h"

#include <iostream>
using namespace std;

int OperatingSystem::_HandleCouter =0;

OperatingSystem::OperatingSystem()
{

}
OperatingSystem::~OperatingSystem()
{
 auto iter = _table.begin();
 for(;iter != _table.end(); ++iter)
 {
  delete (*iter).second;
 }
 _table.clear();

 _handeltable.clear();
}
int OperatingSystem::createProcess(std::string const & processName)
{
 _table.insert( make_pair( OperatingSystem::_HandleCouter,new Process( processName)));

 _handeltable.insert( make_pair( processName, OperatingSystem::_HandleCouter));

 return OperatingSystem::_HandleCouter++;

}
void OperatingSystem::sendMessage(int processHandle, std::string const & message)
{
 auto iter = _table.find(processHandle);
 (*iter).second->excute( message);
}

void OperatingSystem::getHandle(std::string const & processName)
{

 auto iter = _handeltable.find(processName);
 cout<<processName<<"의 HandleCounter는 "<<(*iter).second<<"입니다."<<endl;

}

--HandleBased System.cpp
// HandleBasedSystem.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include "OperatingSystem.h"

int _tmain(int argc, _TCHAR* argv[])
{
 OperatingSystem os;

 int p1Han1d = os.createProcess("Process1");
 int p2Han1d = os.createProcess("Process2");
 int p3Han1d = os.createProcess("Process3");
 
 os.sendMessage(p2Han1d, "running");
 os.sendMessage(p1Han1d, "eating");
 os.sendMessage(p2Han1d, "sleeping");

 os.getHandle("Process1");
 os.getHandle("Process2");
 os.getHandle("Process3");

 return 0;
}

 

'Operations Dev > Handle' 카테고리의 다른 글

map과 make_pair  (0) 2010.12.10