The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe, and simultaneous read accesses to to shared containers are safe. If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.
vc 2003 닷넷에 있는 stl을 멀티스레드에서 사용을 해봤는데 thread safe하지 않는것 같더군요.. 동기화 객체를 이용해서 보호한것과 안한경우를 비교하니까 보호하지 않는 경우 insert나 push_back등에서 포인터에 관한 에러가 발생했습니다..
-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.
-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.
vc 2003 닷넷에 있는 stl을 멀티스레드에서 사용을 해봤는데 thread safe하지 않는것 같더군요.. 동기화 객체를 이용해서 보호한것과 안한경우를 비교하니까 보호하지 않는 경우 insert나 push_back등에서 포인터에 관한 에러가 발생했습니다..
맨 처음 인용해주신 글의 내용을 보면
손님 wrote:
If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.
라고 되어있는데,
여러 쓰레드에서 한개의 map에 접근하고, 그중 한 쓰레드가 쓰기를 할 가능성이 있다면, 동기화 객체를 사용하는 것은 사용자의 책임이므로 알아서 해라.. 라고 되어있는데
말씀 하신것이 이 부분에 해당하는 것 같습니다.
이런 경우를 thread-safe하지 않다고 하지는 않는다고 생각됩니다.
thread-safe하지 않은 것은 localtime 이나 token (인가? 정확히 뭐였더라...; ) 같은 전역 변수를 사용하는 함수들 처럼 두개 이상이 동시에 동작할 수 없는 것들을 말하는 것 같습니다.
이런 경우 mutual exclusion 방법을 사용한다 하더라도 결과가 기대한것과 다르게 나오는 것이죠..
일하는 사람들의 희망 민주노동당 : http://www.kdlp.org
반공 교육의 성과로, 민주주의의 반대가 공산주의(또는 사회주의)라고 생각하는 사람이 많다.
vc 2003 닷넷에 있는 stl을 멀티스레드에서 사용을 해봤는데 thread safe하지 않는것 같더군요.. 동기화 객체를 이용해서 보호한것과 안한경우를 비교하니까 보호하지 않는 경우 insert나 push_back등에서 포인터에 관한 에러가 발생했습니다..
맨 처음 인용해주신 글의 내용을 보면
손님 wrote:
If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.
라고 되어있는데,
여러 쓰레드에서 한개의 map에 접근하고, 그중 한 쓰레드가 쓰기를 할 가능성이 있다면, 동기화 객체를 사용하는 것은 사용자의 책임이므로 알아서 해라.. 라고 되어있는데
말씀 하신것이 이 부분에 해당하는 것 같습니다.
이런 경우를 thread-safe하지 않다고 하지는 않는다고 생각됩니다.
thread-safe하지 않은 것은 localtime 이나 token (인가? 정확히 뭐였더라...; ) 같은 전역 변수를 사용하는 함수들 처럼 두개 이상이 동시에 동작할 수 없는 것들을 말하는 것 같습니다.
이런 경우 mutual exclusion 방법을 사용한다 하더라도 결과가 기대한것과 다르게 나오는 것이죠..
The SGI implementation of STL is thread-
The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe, and simultaneous read accesses to to shared containers are safe. If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.
source: http://www.sgi.com/tech/stl/thread_safety.html
감사합니다.
많은 도움이 된거 같습니다.
노력은 배반하지 않는다.
비주얼 C++에 들어있는 STL은 딩컴에서 만든 걸로 알고 있습니다. S
비주얼 C++에 들어있는 STL은 딩컴에서 만든 걸로 알고 있습니다. SGI 버전을 쓸려면 STLPort를 설치해야 합니다.
느낌상 쓰레드 구현은 딩컴도 위에 나온 것과 비슷한 수준일 것 같긴 합니다.
vc 2003 닷넷에 있는 stl을 멀티스레드에서 사용을 해봤는데 thr
vc 2003 닷넷에 있는 stl을 멀티스레드에서 사용을 해봤는데 thread safe하지 않는것 같더군요.. 동기화 객체를 이용해서 보호한것과 안한경우를 비교하니까 보호하지 않는 경우 insert나 push_back등에서 포인터에 관한 에러가 발생했습니다..
-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.
[quote="chadr"]vc 2003 닷넷에 있는 stl을 멀티스레드
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrfthreadsafetyinstandardclibrary.asp
MFC가 아닌 일반적인 프로젝트는 MT 옵션들이 기본적으로 안 붙음.
_____________________________
언제나 맑고픈 샘이가...
http://purewell.biz
[quote="purewell"][quote="chadr"]vc 2003
물론 MT옵션을 붙인 상태에서 사용했었습니다.. 그래도 문제가 발생하더라구요.. 흠...
-------------------------------------------------------------------------------
It's better to appear stupid and ask question than to be silent and remain stupid.
[quote="prolinko"]비주얼 C++에 들어있는 STL은 딩컴에
SGI와 STLPort는 다른 구현입니다.
ps. 거의 모든 STL 구현에서 thread safe는 읽기만 해당됩니다.
[quote="chadr"]vc 2003 닷넷에 있는 stl을 멀티스레드
맨 처음 인용해주신 글의 내용을 보면
라고 되어있는데,
여러 쓰레드에서 한개의 map에 접근하고, 그중 한 쓰레드가 쓰기를 할 가능성이 있다면, 동기화 객체를 사용하는 것은 사용자의 책임이므로 알아서 해라.. 라고 되어있는데
말씀 하신것이 이 부분에 해당하는 것 같습니다.
이런 경우를 thread-safe하지 않다고 하지는 않는다고 생각됩니다.
thread-safe하지 않은 것은 localtime 이나 token (인가? 정확히 뭐였더라...; ) 같은 전역 변수를 사용하는 함수들 처럼 두개 이상이 동시에 동작할 수 없는 것들을 말하는 것 같습니다.
이런 경우 mutual exclusion 방법을 사용한다 하더라도 결과가 기대한것과 다르게 나오는 것이죠..
일하는 사람들의 희망 민주노동당 : http://www.kdlp.org
반공 교육의 성과로, 민주주의의 반대가 공산주의(또는 사회주의)라고 생각하는 사람이 많다.
[quote="쌀밥"][quote="chadr"]vc 2003 닷넷에 있
http://en.wikipedia.org/wiki/Thread-safety
'여러 쓰레드에서 한개의 map에 접근하고, 그중 한 쓰레드가 쓰기를 할 가능성이 있다면, 동기화 객체를 사용하는 것은 사용자의 책임이므로 알아서 해라' 라는건 '이건 Thread-safe하지 않으니 알아서 achieve thread-safety 하여라' 아닌가요?
앗, 그리고 전역변수를 사용하는 함수의 경우에 thread-safe한 코드를 만들 수 없는 경우가 있나요? 언뜻 떠오르는게 없는데 설명좀 부탁드립니다.
;-)
--
http://www.deisys.net
댓글 달기