logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

RE: Thread::sleep() implementation bug on Solaris: msg#00048

apache.logging.log4cxx.user

Subject: RE: Thread::sleep() implementation bug on Solaris

Could somebody react on my mail.
 
thanks,
Toly Kournik
-----Original Message-----
From: Anatoly Kournik [mailto:AnatolyK@xxxxxxxxxx]
Sent: Monday, September 13, 2004 11:15 AM
To: log4cxx-user@xxxxxxxxxxxxxxxxxx
Subject: Thread::sleep() implementation bug on Solaris

Hi,
 
using usleep in Thread::sleep() implementation on Unix(Solaris) is problematic in multithreaded environment
because  it's implemented by setting an alarm signal and pausing until it occurs.
Since SIGALRM shouldn't be blocked or ignored during a call, if context switch occurs when it's delivered, the programm simply quits (default action on SIGALRM).
The proper way is to use nanosleep function. It has no effect on the action or blockage of any signal.
 
Here is an example of nanosleep usage.
I've encapsulated call to nanosleep in signal blocking/unblocking routines in order to prevent signals delivery. 
 

sigset_t newset, oldset;

sigfillset(&newset);

pthread_sigmask(SIG_BLOCK, &newset, &oldset);//block signals

struct timespec sleeptime;

sleeptime.tv_sec = ms / 1000; //argument is supplied in milliseconds

sleeptime.tv_nsec = 0;

if(nanosleep(&sleeptime, NULL)) perror("nanosleep");

pthread_sigmask(SIG_SETMASK, &oldset, NULL);//restore signals

--
Toly Kournik
 

--------------------------------------------------------------------------------------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please notify the originator of the message.
Scanning of this message is performed by SurfControl E-mail Filter software in conjunction with virus detection software.

--------------------------------------------------------------------------------------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please notify the originator of the message.
Scanning of this message is performed by SurfControl E-mail Filter software in conjunction with virus detection software.
<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo