LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-20-2013, 01:41 PM   #1
govikes
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Rep: Reputation: Disabled
Unhappy mlock question


I want to use mlock to lock portions of my application process into memory, so it doesn't get swapped out. I would like to "mlock" the text segement, data segment, BSS segment and heap segment of my application process - how do I find the start address and length of each of these 4 segments of my application process?

Thanks in advance for your help...
 
Old 03-22-2013, 07:35 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Have you considered running a system that has no swap space?
 
Old 03-22-2013, 11:10 AM   #3
govikes
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
No, I haven't thought of that before. Is that fairly easy to configure/setup?
 
Old 03-22-2013, 12:38 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Don't try to do that ... anyway, you can't. An application can "wire" a few pages into memory, maybe, but you can't make an entire application non-swappable.

If you're worried about this sort of thing .. buy more RAM, and/or run fewer applications in the system. Or impose "ulimit"s on what the individual applications can potentially allocate.

The system will never steal a page unless it's been reduced to stealing in order to survive. If you can demonstrate that your application is being adversely affected by swapping, then the root cause to be dealt-with is not a microscopic one but a much bigger picture.
 
Old 03-22-2013, 12:40 PM   #5
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
At install time you get prompted to define a swap partition (or logical volume if you lean that way). After installation while running normally you remove the swap line from /etc/fstab and reboot. You now have a spare partition you can repurpose.

Then all your processes will refrain from any paging/swapping with no extra effort.
 
Old 03-22-2013, 12:46 PM   #6
govikes
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks for all of the advice. At this point, I'm only interested in locking/pinning certain segments of an applicaiton into memory using the mlock function. However, I'm not sure how to find out the starting address and length of each segment. It appears to be available in kernel space via the mm_struct, but not sure how to access that information in the application itself?
 
Old 04-18-2013, 03:42 PM   #7
govikes
LQ Newbie
 
Registered: Mar 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
#sundialsvcs - I'm curious to understand why you believe that an entire application can't be "wired" into memory and made non-swappable? Thanks
 
  


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
[SOLVED] GPL question (Version 2, June 1991) - physical media availability question LicenseQuestions Linux - Newbie 1 12-01-2012 06:34 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
linux distro question & mysql install question natalie.aloi Linux - Newbie 5 07-19-2009 08:28 PM
mlock() function tedg Linux - Kernel 1 01-19-2007 04:08 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:34 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