LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 11-13-2008, 02:49 PM   #1
foof
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Rep: Reputation: 0
Question I (sometimes) cant write my program file when a copy of it is running


Can anyone answer this?

If I write a small program and run it, and while it is running, I try to rebuild (or in any way modify the program file), on Linux, I am (sometimes) not allowed to write to the file. Why?

It has something to do with memory management.
 
Old 11-13-2008, 03:04 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
welcome to LQ!!

In general, you cannot write to a file when it is in use. I would assume that includes a file which is a program. I don't think this is memory management--I think it is the filesystem.

Tell us more about the program--what it does, what language, etc.---and what exactly happens when you try to do something.
 
Old 11-13-2008, 03:14 PM   #3
foof
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Actually it is question in an operating system course I am taking. We are currently studying memory management. That is why I know the answer has to do with memory management. I have search the text and internet and have not found any info that touches on this. I don't have access to Linux source as of this moment so I figure I'd put the question out the people with Linux experience.
 
Old 11-13-2008, 03:20 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Thank you for acknowledging that this is homework...

But now I am really confused as to what the question is. It now appears you are asking something purely hypothetical. If the question in fact relates to not being able to write to a file that is in use, I can't see how that is a memory management issue.
 
Old 11-13-2008, 04:00 PM   #5
foof
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Original Poster
Rep: Reputation: 0
The question is not hypothetical as the instructor showed an example of it in class.
I think it has to do with the fact that when you change a program and recompile you change the virtual address space of the executable image. Since the text segment (shareable in Linux) is already in physical memory and being used by the copies already running, if the new version were to be run, it would be run with the old text segment. Something along those lines although I dont know, the reason for the question.
 
Old 11-13-2008, 04:08 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
My take is that you do not understand the question. That being the case, how can we help with the answer?

You talk about compiling and running. When you run a binary (compiled program) it loads itself into memory**. When you quit, it frees the memory---the next time you run it, it could easily go somewhere else. In this context, what do you mean by the "text segment"?

**A complex program would load PART into memory.
 
Old 11-13-2008, 04:17 PM   #7
foof
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Original Poster
Rep: Reputation: 0
You maybe right, I might not understand the question. I will have to verify it with the instructor. Thanks for your patience and help.
 
  


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
Copy line from file and write it to another file shokeer Linux - Newbie 2 11-01-2008 06:54 AM
in search of copy-on-write file system exponential Linux - General 1 08-17-2007 10:35 AM
How to write script with check running program VooZ2_uk Programming 3 12-13-2006 09:57 AM
Exercise 1-9. Write a program to copy its input to its output, replacing each string zombi3 Programming 3 12-21-2003 02:28 AM
how to write a program can have 2 threads running at the same time?? man9 Programming 3 10-07-2000 01:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 PM.

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