?
Solved

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

Posted on 2003-03-29
6
Medium Priority
?
217 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:zoomtosara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:bryanh
ID: 8263007
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.
0
 

Author Comment

by:zoomtosara
ID: 8275873
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
0
 
LVL 5

Accepted Solution

by:
bryanh earned 300 total points
ID: 8276299
First of all, take that "free" memory number with a grain of salt.  Linux frees up memory as it needs it; the amount free at this moment is not very meaningful.

Even if you have 0 "free" memory, it's normal to have no swap space used.  Back when memory was expensive, swapping was normal, but today there are lots of 128M systems that don't even _have_ swap space.

The 99% CPU usage is probably a problem, but the solution would more likely be in fixing the program so it demands less CPU time than in making Linux give it less.

What do the threads do?  One would expect them to wait for something (e.g. for a message on to arrive on a socket or for a signal from another thread to arrive), but instead they are constantly executing something.
0
 

Author Comment

by:zoomtosara
ID: 8290542
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
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10225219
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
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question