Sponsored Content
Full Discussion: while loop and CPU ..
Top Forums Programming while loop and CPU .. Post 302229414 by nivea_jmd on Wednesday 27th of August 2008 12:50:07 AM
Old 08-27-2008
while loop and CPU ..

Hello frnds..

i m using while loops in my code.. bec of that my application uses almost 90% of CPU resources.. its not lettin others applications to run..

actually i have to read some signal from serial port... n till i dont get it high or low..
i have to read that signal continuously... its for this reason i m using while loops.


while(1)
{
status=read_CTS();
if(status==1)
continue;
else if(status==0)
{

---------
some code
--------

break;
}
}


someone suggested me to use sleep in the while loop..
i cant use it bec we are workin on realtime systems...
so we usually avoid using delay n sleep....

can anyone help me on this ???

my application is on C++/fedora
 

10 More Discussions You Might Find Interesting

1. Solaris

How to down a particular CPU in a server, witch is having 16 CPU's

Hi.., my dout is a solaris server is having 16 cpu's. in tht one cpu running some error process, accupaying more space. I wanna down tht particular CPU only with out interrupting the other 15 CPU's. how can i do this. is there any command for this ?? (5 Replies)
Discussion started by: b.janardhanguru
5 Replies

2. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

3. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

4. Solaris

Infinite for loop is taking too much CPU usage %

Hi All, I wrote one simple for loop shell script which prints number..but this loop is infinite...but its taking lot of CPU (15.7) %. if i am using sleep cmd then cpu usage become 0.4 %. Is there anyway to reduce this CPU usage without using sleep cmd? i dont want 2 use sleep cmd... (7 Replies)
Discussion started by: pa.chidhambaram
7 Replies

5. Solaris

cpu-shares vs cpu-cap in solaris

Can anyone tell me difference between cpu-shares vs cpu-cap in solaris & how FSS will work with cpu-caps ? (9 Replies)
Discussion started by: fugitive
9 Replies

6. Solaris

CPU and CPU-Utilization

Hi, I am a weblogic Admin I our env there are 5 servers running in one Solaris 10 Sparc machine. But when i tried for process status using <top> command I got the following output load averages: 1.75, 2.18, 2.12; up 134+08:28:49 22:24:21 79 processes: 77 sleeping, 1 running,... (1 Reply)
Discussion started by: Joseph Antoine
1 Replies

7. Solaris

Difference between CPU CHIP and CPU ID

Hi All, What is the difference between CPU CHIP and CUP ID on SUN/ Oracle M5000 servers.. Thanks in advance (3 Replies)
Discussion started by: kumarmani
3 Replies

8. UNIX for Dummies Questions & Answers

Is it possible to combine multiple CPU to act as a single CPU on the same server?

We have a single threaded application which is restricted by CPU usage even though there are multiple CPUs on the server, hence leading to significant performance issues. Is it possible to merge / combine multiple CPUs at OS level so it appear as a single CPU for the application? (6 Replies)
Discussion started by: Dissa
6 Replies

9. AIX

Entitled CPU lesser Than Used CPU !!

Hi All, It may be a n00b question, but i really want to know , How Entitled Capacity is less and Used CPU is more when there is no Free CPU is available in the managed system. I have 5LPARs in a MS with Dual VIO. Managed System CPU details Available: 0.20 Assigned to partitions: 15.80... (11 Replies)
Discussion started by: Thala
11 Replies

10. UNIX for Beginners Questions & Answers

Why Entitlement CPU can't be set to same as Virtual CPU?

I read that Entitlement CPU should be set to max 75% compare to Virtual CPU. May I know the reason. I have set the Entitlement CPU = Virtual CPU on AIX . It works fine . Can you help to understand. (1 Reply)
Discussion started by: gabhanes
1 Replies
sleep(1)							   User Commands							  sleep(1)

NAME
sleep - suspend execution for an interval SYNOPSIS
/usr/bin/sleep /usr/bin/sleep time ksh93 sleep time DESCRIPTION
/usr/bin/sleep sleep suspends execution for at least the integral number of seconds specified by time. ksh93 sleep suspends execution for at least the time in seconds specified by time or until a SIGALRM signal is received. OPERANDS
/usr/bin/sleep The following operands are supported for /usr/bin/sleep: time time in seconds can be specified as a non-negative decimal integer number. ksh93 The following operands are supported: time Specify time in seconds as a floating point number. The actual granularity depends on the underlying system, normally around 1 mil- lisecond. EXAMPLES
Example 1 Suspending Command Execution The following example executes a command after a certain amount of time: example% (sleep 105; command)& Example 2 Executing a Command Every So Often The following example executes a command every so often: example% while true do command sleep 37 done ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of sleep: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 The execution was successfully suspended for at least time seconds, or a SIGALRM signal was received (see NOTES). >0 An error has occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/sleep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ ksh93 +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Uncommitted | +-----------------------------+-----------------------------+ SEE ALSO
ksh93(1), wait(1), alarm(2), sleep(3C), wait(3UCB), attributes(5), environ(5), standards(5) NOTES
If the sleep utility receives a SIGALRM signal, one of the following actions is taken: o Terminate normally with a zero exit status. o Effectively ignore the signal. The sleep utility takes the standard action for all other signals. SunOS 5.11 20 Nov 2007 sleep(1)
All times are GMT -4. The time now is 12:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy