[ace-users] [quesion] on ACE_Thread_Manager
Jeong Ho Lee
friend25kr at gmail.com
Wed Jul 11 03:30:04 CDT 2007
Dear, all.
ACE VERSION: 5.5.4
HOST MACHINE and OPERATING SYSTEM:
Host Machine: Intel Centrio Duo 2GHz meory 1.5GB
OS: Windows Professional SP2
TARGET MACHINE and OPERATING SYSTEM: Same with Host Machine and OS
THE $ACE_ROOT/ace/config.h FILE
#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#define ACE_HAS_MFC 1
#define ACE_NO_INLINE
#include "ace/config-win32.h"
AREA/CLASS/EXAMPLE AFFECTED:
ACE_Thread_Manager
DOES THE PROBLEM AFFECT:
EXECUTION
SYNOPSIS:
occurrance of excpetion on the function callled
"thread_mutex_lock" in the file
of os_ns_thread.inl
DESCRIPTION:
When executing my simple program based on ACE_Thread_Manager,
an exception occures at the marked point:
ACE_INLINE int
ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m)
{
// ACE_OS_TRACE ("ACE_OS::thread_mutex_lock");
#if defined (ACE_HAS_THREADS)
# if defined (ACE_HAS_WTHREADS)
-> ::EnterCriticalSection (m);
return 0;
# elif defined (ACE_HAS_STHREADS) || defined (ACE_HAS_PTHREADS)
|| defined (ACE_VXWORKS)
return ACE_OS::mutex_lock (m);
my simple program as followed
testthread.cpp
#include "stdafx.h"
#include "Thread.h"
int main(int argc, char* argv[])
{
CThread thread;
thread.start(10);
return 0;
}
thread.h
#pragma once
class CThread
{
public:
CThread(void);
public:
~CThread(void);
private:
struct Thread_Args
{
public:
Thread_Args(/*unsigned short id,*/ CThread* lsp) :
/*id_(id),*/ this_(lsp) {}
CThread* this_;
// unsigned short id_;
};
static void* run_svc (void* arg);
public:
void start(unsigned short);
};
thread.cpp
#include "StdAfx.h"
#include "Thread.h"
#include <iostream>
#include "ace/Basic_Types.h"
#include "ace/Thread_Manager.h"
#include "ace/Log_Msg.h"
using namespace std;
CThread::CThread(void)
{
}
CThread::~CThread(void)
{
}
void* CThread::run_svc(void* arg)
{
while(1)
{
cout << "1" << endl;
}
/*
// Thread_Args *thread_args = ACE_static_cast(Thread_Args*, arg);
// for(int i = 0; i < thread_args->id_; i++)
// cout << thread_args->id_ << " is running" << endl;
// delete thread_args;
*/
return 0;
}
void CThread::start(unsigned short id)
{
Thread_Args *thread_args = new Thread_Args(/*id,*/ this);
if(ACE_Thread_Manager::instance()->spawn((ACE_THR_FUNC)CThread::run_svc,
ACE_static_cast(void*, thread_args), THR_DETACHED |
THR_SCOPE_PROCESS) == -1)
return;
}
More information about the Ace-users
mailing list