C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 27th, 2004, 06:05 PM
modamax modamax is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 30 modamax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
What does it mean for a thread operation to be "async-signal safe" ?

Thanks!

Reply With Quote
  #2  
Old October 27th, 2004, 11:19 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,390 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 32 m 40 sec
Reputation Power: 4080
An async signal safe function can execute many instances of the function in parallel.

Say, you have a function func1() that is called every time a certain signal occurs. Now when the signal happens, func1() gets executed and let's say the first thing it does is re-enable the signal handler. Now there's a chance that the signal can be triggered again while the code inside func1() is executing. Let's say the signal occurs again and again func1() is fired off. Now there are two copies of the func1() code running because the signal fired twice. If the function is async signal safe, the second instance of func1() running should not affect any of the running of the first instance of func1() (e.g.) if the second instance sets any variable values, those values will NOT be reflected in the first instance.

Say func1() calls things like fopen(), fclose() etc. within it. These functions are not async-signal-safe because they use some global variables within their code and if two instances of fopen() get triggered simultaneously, one of them may change a global variable that the other has set to some value and thus one instance of fopen() may not work right. This makes func1() also not async-signal-safe because two instances of func1() may not always run successfully in parallel. On the other hand, the kernel I/O functions open(), close() etc. are async thread safe as they don't use global variables in their code and if one instance of open() changes the value of a variable, the other instance doesn't see it. So, if func1() uses open()/close() instead of fopen(), fclose(), then two or more instances can safely run in parallel and hence func1() becomes async-signal-safe.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Last edited by Scorpions4ever : October 27th, 2004 at 11:22 PM.

Reply With Quote
  #3  
Old October 28th, 2004, 12:22 AM
modamax modamax is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 30 modamax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Cool.

That's really good
thanks..

Reply With Quote
  #4  
Old October 28th, 2004, 12:40 AM
nmainak nmainak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Iowa
Posts: 37 nmainak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 45 m 19 sec
Reputation Power: 9
Thats an awesome response scorpion. I also had a similar question and now I know. Good job.

Reply With Quote
  #5  
Old October 28th, 2004, 07:04 AM
nnxion's Avatar
nnxion nnxion is offline
Last Day: May 29, 2005
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Location: elemental sphere
Posts: 742 nnxion User rank is Lance Corporal (50 - 100 Reputation Level)nnxion User rank is Lance Corporal (50 - 100 Reputation Level)nnxion User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 5 Days 7 h 20 m 20 sec
Reputation Power: 9
nice explanation scorpion

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > What does it mean for a thread operation to be "async-signal safe" ?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap