#94 scsh wastes cpu time

open
nobody
run-time (53)
5
2012-07-11
2012-07-11
No

When I run a scsh script that launches an external program the scshvm
process uses half of the available CPU time. I'm using scsh 0.6.7 on Xubuntu11.10. In order to demonstrate the bug
do the following:

1. Compile the file cprogram.c.
2. Launch the script scsh-script.scsh from a Unix shell.
3. While the script is running execute command

ps -eo comm,time,etime,%cpu

from another terminal.

The %cpu field should be a little less than 50 for both the
scsh-script and cprogram processes. By dividing time field with etime
field you see that both processes are really using half of the cpu time.

File cprogram.c:
--- cut here ---
#include <math.h>
#include <stdio.h>

#define COMPUTATION_SIZE 1000000000

int main( void )
{
double r = 0.0;
int i = 0;
for( i = 0; i < COMPUTATION_SIZE; i++ )
{
r = cos( r );
}
printf( "Result: %f\n", r );
return 0;
}
--- cut here ---

File scsh-script.scsh:
--- cut here ---
#!/usr/bin/scsh \ -e main -s
!#

(define (main args)
(run ("./cprogram")))
--- cut here ---

- Tommi Höynälänmaa

Discussion

  •  
    Attachments