LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2005, 08:40 PM   #1
lordofring
Member
 
Registered: Feb 2005
Posts: 91

Rep: Reputation: 15
global integer in the multi-thread application


Hello,

My multithread application shares 1 global integer. There is only one thread which is able to modify the integer. All other threads only read the value. My question is, do I need to protect the global integer? Since only one thread modify it and the command will be only one instruct, I don't think that it needs synchronize. If it's true, why there is atomic_t for integer?

Thanks.
 
Old 08-23-2005, 09:36 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Quote:
the command will be only one instruct
Don't be too sure of that. While it's only one instruction/statement/whatever in your source language, it might be more than one in your target language.

I'd say syncronize--rather safe than sorry.

hth --Jonas
 
  


Reply



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
Natural Disasters/Global Warming Thread. rvijay General 10 08-17-2005 01:06 PM
Multi-Thread/Process Pipes JanusPaul Programming 2 02-27-2005 02:52 PM
multi-thread VS multi-process ltcstyle Programming 3 12-04-2004 06:53 PM
how to debug multi threaded application sibtay Programming 3 10-15-2004 12:02 PM
Multi-thread debugging with gdb on RedHat 9.0 Rodney Riggs Linux - Software 0 09-23-2003 04:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration