LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-12-2005, 01:46 AM   #1
gecoool
Member
 
Registered: Feb 2005
Location: Romania
Distribution: Fedora 2
Posts: 38

Rep: Reputation: 15
Smile read only acces to shared resource


Hello everyone. I want to know if it is safe to acces read-only a global variable (shared resource) without protecting it with a mutex (C++).


THX
 
Old 09-12-2005, 10:01 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,472

Rep: Reputation: 154Reputation: 154
"Hello everyone. I want to know if it is safe to acces read-only a global variable (shared resource) without protecting it with a mutex (C++)."

As long as every thread is accessing the variable as read only then you do not need to lock on the global variable. However if any thread updates the variable then all threads which update the variable must use an exclusive lock and all threads which are read only on the global variable must use a shared lock.

-------------------------
Steve Stites
 
Old 09-13-2005, 12:54 AM   #3
gecoool
Member
 
Registered: Feb 2005
Location: Romania
Distribution: Fedora 2
Posts: 38

Original Poster
Rep: Reputation: 15
Smile

Thanks a lot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent !!! rpm: error while loading shared libraries: libelf.so.1: cannot open shared tinaa Linux - Software 5 12-02-2008 03:19 PM
read-only shared mount between linux and w2k server fostiator Linux - Networking 1 06-10-2004 03:14 AM
I only have read acces on remote connection Stuartb21 Linux - Networking 1 02-12-2004 05:45 PM
skins for xmms if /usr/shared is read only chalias101 Linux - Distributions 2 12-20-2003 04:59 PM
Impossible to acces/read/write on my Zip Disk ordx Linux - Hardware 4 12-01-2003 11:32 AM


All times are GMT -5. The time now is 07:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration