|
|
Sponsor |
Thread::sleep() implementation bug on Solaris: msg#00026apache.logging.log4cxx.user
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.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Question regarding FileAppender..., Curt Arnold |
|---|---|
| Next by Date: | Re: Question regarding FileAppender..., Mike SG |
| Previous by Thread: | Question on logger hierarchy, Robert Haschke |
| Next by Thread: | RE: Thread::sleep() implementation bug on Solaris, Anatoly Kournik |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|