Link to home
Start Free TrialLog in
Avatar of zoomtosara
zoomtosara

asked on

controlling SWAP mem and CPU Utilization thru C coding..disabling multi-user mode

Hi!!

I have a multi-threaded application(3 threads to be precise and 1 root thread)developed in C on linux..When i run this application, two threads use quite large amt of of CPU resources and abt 126 MB of my 128 MB RAM while swap is not at all used..Is it possible to include the code for controlling balance between swap and RAM being used in the application or is it some setting within some linux files????And how is possible to decrease the CPU utilization???

One more thing..i start my application using a shell script..i want whenever that shell script runs, user should be able to switch betwen screens using Ctrl-Alt-F1, etc(to disable multi-user mode)..How can that be done??i am able to find trapping interrupts like Ctrl Z but not this..


Paridhi
Avatar of bryanh
bryanh

First of all, you don't mention what else is going on in this system.  If there is nothing but these 3 threads, then it doesn't make any sense to try to reduce their resource utilization.  So I'm going to assume that there is something else in the system that you would like to have a greater share of real memory and CPU time.

The most basic way to control allocation of CPU time is with process priority.  See the section on process control in the GNU C library user's guide (usually 'info libc').  And 'man nice'.

There is no direct way to control a process' real memory allocation, but it tends to follow its CPU allocation.  The less a process runs, the less real memory it will have on average.

But reading your question again, it sounds like no swap space is getting used by anything, which means your system has enough real memory to fill everyone's needs, which means there's nothing you can do to stop the system from using the real memory.  Unused real memory is just a waste.


I don't have an answer for your other question.  Note:  EE works best when you post multiple questions as separate questions.
Avatar of zoomtosara

ASKER

HI!!

Thanx for ur reply..i have a tomcat server running on my system apart from my application...but that too doesn't consume any memory..what i have observed on various linux systems running proxy server, mail server, like applications is that they just use 2-3% of CPU resources and in case of memory also, both system RAM and SWAP are  used simultaneously(using top command) even though the RAM is free..

but in my case, the CPU resources are shown utilized abt 99% and no swap is used though just 28MB of RAM is shown free out of 128MB..i tried accessing tomcat from some client machines..at that moment, when a new java thread is started, the cpu utilization by the application threads gets reduced a little but then back to same(arnd 99%)..

so what i wnated to know is that is it the coding style because of which my application is utilizing such huge amount of cpu resources or some system setting...

Paridhi
ASKER CERTIFIED SOLUTION
Avatar of bryanh
bryanh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, the two threads are continuously monitoring one linked list each for specific entries before they delete those found matching...This is all these two threads are doing..
Can this be the cause of 99% memory utiization..but i don't think this execution is so much cpu intensive...it's just few comparisons......

Paridhi
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bryanh {http:#8276299}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer