Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2007
Jacky_Lee Jacky_Lee is offline
Registered User
 
Name: jacky lee
Organization: ustb
Project: graduate student recearch
 
Join Date: Jul 2006
Posts: 13
Question monitor util thread block at windows system

hi
i have a problem with monitor class at windows. I made a queue with monitor class, use notify() in put and timedwait() in get. when i have several(>20) thread to get and 1 thread to put, the thread will block. i pause the program , found one of the get thread blocked at _gate.wait() of prewait(), and another get thread blocked at _queue.wait() of postwait().

these is my test code
Code:
#include <IceUtil/Thread.h>
#include <IceUtil/Time.h>
#include <IceUtil/Monitor.h>
#include <Ice/Ice.h>
#include <iostream>
#include <list>

template<class t> class Queue: public IceUtil::Monitor<IceUtil::Mutex>
{
public:
	Queue(){};
	void put(const t & item) {
		IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
		_q.push_back(item);
		notify();
	}
	bool timedGet( t & ret, const IceUtil::Time& timeout)
	{
		IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
		if (_q.size() == 0)
			timedWait(timeout);
		if (_q.size() == 0)
		{
			return false;
		}
		ret = _q.front();
		_q.pop_front();
		return true;
	}
private:
	std::list<t> _q;
};

Queue<int> m_pQ;
class testthread : public IceUtil::Thread
{

public:
	virtual void run()
	{
		int n = 0;
		srand((int)IceUtil::Time::now().toMicroSeconds());
		while(true)
		{
			int Result;
			int nTime = rand() % 1000;
			m_pQ.timedGet(Result, IceUtil::Time::microSeconds(nTime) );
			Sleep(10);
			std::cout << nTime << " ";
		}
	}
};
void main()
{
	for (int i = 0; i < 100; i++)
	{
		testthread* p = new testthread;
		p->start();
	}
	while(true)
	{
		m_pQ.put(2);
		Sleep(1);
	}
	return;
}
__________________
Jack Lee
University of science and technology of beijing
Reply With Quote
  #2 (permalink)  
Old 05-30-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,055
Thanks for the problem report. We're looking into the problem.
Reply With Quote
  #3 (permalink)  
Old 05-30-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,055
BTW, can you fix the name in your profile please? You are required to give your full real name in your profile for free support on these forums.
Reply With Quote
  #4 (permalink)  
Old 05-30-2007
Jacky_Lee Jacky_Lee is offline
Registered User
 
Name: jacky lee
Organization: ustb
Project: graduate student recearch
 
Join Date: Jul 2006
Posts: 13
ok, i have changed
__________________
Jack Lee
University of science and technology of beijing
Reply With Quote
  #5 (permalink)  
Old 06-01-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,055
Thanks for the bug report and test case. I've posted a patch that fixes this problem. Please see patch #3 for Ice 3.2: Fix for condition variable implementation under Windows. for details.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
IcePatch2/Util.cpp namespace resolution problem on Solaris 10 / Sun Studio 10 failys Bug Reports 1 11-17-2005 10:17 AM
typedef for Monitor? acbell Comments 1 10-12-2005 03:30 PM
Windows Installer assumes System Drive is on C: RyanFogarty Comments 5 02-08-2005 08:19 AM
Queue example and IceUtil::Monitor RyanFogarty Help Center 6 12-08-2004 02:51 PM
using Monitor segfaults timruijs Help Center 2 07-19-2004 11:37 AM


All times are GMT -4. The time now is 08:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.