Is there a way to move a process from RAM to swap space in C code
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there a way to move a process from RAM to swap space in C code
Hi All,
hope someone can advise on this, I need to run 4 processes though only two are in use at any instance, but I need to swap between which are. Right now I pause a process then unpause the one I wish to use next. However I can have memory issues, that is I run out of RAM. So rather than reload each process from disk, which is slow, I thought I'd try to save load time by loading the process into RAM, then moving to swap space when not running. When I need it load from swap space to RAM again. Firstly is this possible? Secondly will it save time. Thanks in advance.
Yes, and the kernel is smarter. For example, you have one program that uses some code segments and some data segments. Writing the code segment to swap is pointless as the code already is on disk. So the kernel will simply drop the code segment when more RAM is needed, and load it back later later. Moving the code to swap makes no sense.
Hi All,
hope someone can advise on this, I need to run 4 processes though only two are in use at any instance, but I need to swap between which are. Right now I pause a process then unpause the one I wish to use next. However I can have memory issues, that is I run out of RAM. So rather than reload each process from disk, which is slow, I thought I'd try to save load time by loading the process into RAM, then moving to swap space when not running. When I need it load from swap space to RAM again. Firstly is this possible? Secondly will it save time. Thanks in advance.
So rather than reload each process from disk, which is slow, you want to put it on disk but it feels better when the region where you put it is called swap?
make it simple ,
dump the data of unused processes to disk and put the process to sleep, if you have luck they are in the disk cache and fast swapping between the processes is not an issue, or it is in /tmp which is mounted to tempfs anyway :-), however, if is on disk it depends if reading form file is not very noticeable faster or slower than from swap.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.