![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: May 2008
Posts: 7
Rep Power: 0
![]() |
On linux using pthreads, if I have a 2-bytes variable x shared by pthreads used only in the following ways:
(1) x=value; if (x==value) {do something (not with x)}other variable (not shared) = x; Is it correct to define it sig_atomic_t x; (no matter if 4 or 2 bytes) and AVOID to protect every instruction of kind (1) or (2) or (3) with pthread_mutex_lock()/trylock() before and pthread_mutex_unlock() after ? Can I be sure there is no race condition/unpredicted event/problem? In a few words: is it correct to speed up a software using sig_atomic_t data instead of mutexed data with the fundamental condition that data are as little as 2-4 bytes and are accessed only in the very simple way above? Thanks |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Avoid Connecting To MySQL Multiple Times | Sane | Python | 4 | Nov 23rd, 2007 12:42 PM |
| Avoid default dialog box for file download? | java_roshan | Other Web Development Languages | 1 | Sep 12th, 2006 9:38 PM |
| Repetitive replacing sections of text files | Novice | Other Scripting Languages | 2 | Jun 17th, 2005 9:07 AM |
| How Avoid Dialog Box Open/Save Files | see07 | C# | 3 | Mar 30th, 2005 7:06 AM |