Sponsored Content
Full Discussion: while loop and CPU ..
Top Forums Programming while loop and CPU .. Post 302229610 by otheus on Wednesday 27th of August 2008 09:57:14 AM
Old 08-27-2008
The standard call is select(). Do a "man 2 select". It's a little difficult to understand at first, and maybe you have only one file descriptor to wait on, so you can do a man on poll(), but it's not portable to older UNIX's. Here, you can do:

Code:
struct pollfd pollfd_list[] = { 0 /*stdin */, ~0 /* all events */, 0 };
poll( pollfd_list, 1 /* 1 file descriptor */, 1000 /* 1 second */ );

This will return at the latest every second (unless your process is pushed out due to other processes -- Linux isn't realtime) and whether or not you have something to do depends on the last field in pollfd_list.
 

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
break(1)                                                           User Commands                                                          break(1)

NAME
break, continue - shell built-in functions to escape from or advance within a controlling while, for, foreach, or until loop SYNOPSIS
sh break [n] continue [n] csh break continue ksh *break [n] *continue [n] DESCRIPTION
sh The break utility exits from the enclosing for or while loop, if any. If n is specified, break n levels. The continue utility resumes the next iteration of the enclosing for or while loop. If n is specified, resume at the n-th enclosing loop. csh The break utility resumes execution after the end of the nearest enclosing foreach or while loop. The remaining commands on the current line are executed. This allows multilevel breaks to be written as a list of break commands, all on one line. The continue utility continues execution of the next iteration of the nearest enclosing while or foreach loop. ksh The break utility exits from the enclosed for, while, until, or select loop, if any. If n is specified, then break n levels. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be exited. The continue utility resumes the next iteration of the enclosed for, while, until, or select loop. If n is specified then resume at the n- th enclosed loop. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be used. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words that follow a command preceded by ** that are in the format of a variable assignment are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign, and also that word splitting and file name genera- tion are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), exit(1), ksh(1), sh( 1), attributes(5) SunOS 5.10 17 Jul 2002 break(1)
All times are GMT -4. The time now is 06:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy