File: ut.c

package info (click to toggle)
xpvm 1.2.5-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,368 kB
  • ctags: 1,509
  • sloc: ansic: 22,799; tcl: 7,750; makefile: 101; csh: 11; sh: 10
file content (961 lines) | stat: -rw-r--r-- 16,319 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961

static char rcsid[] = 
	"$Id: ut.c,v 4.50 1998/04/09 21:12:01 kohl Exp $";

/*
 *         XPVM version 1.1:  A Console and Monitor for PVM
 *           Oak Ridge National Laboratory, Oak Ridge TN.
 *           Authors:  James Arthur Kohl and G. A. Geist
 *                   (C) 1994 All Rights Reserved
 *
 *                              NOTICE
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby granted
 * provided that the above copyright notice appear in all copies and
 * that both the copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Neither the Institution, Oak Ridge National Laboratory, nor the
 * Authors make any representations about the suitability of this
 * software for any purpose.  This software is provided ``as is''
 * without express or implied warranty.
 *
 * XPVM was funded by the U.S. Department of Energy.
 */


/* XPVM Headers */

#include "xpvm.h"

#include "globals.h"


void
utHandle( new, ssec, susec, esec, eusec )
int new;
int ssec;
int susec;
int esec;
int eusec;
{
	UT_STATE U;
	UT_STATE Utmp;
	UT_STATE Utmp2;

	UT_STATE last;

	char cmd[1024];

	int HT;

	int cmps, cmpe;
	int ts, te;
	int scale;
	int draw;
	int flag;
	int tmp;
	int tot;
	int i;

	REFRESH_GLOBAL( UT_RUNNING_COLOR );
	REFRESH_GLOBAL( UT_SYSTEM_COLOR );
	REFRESH_GLOBAL( UT_IDLE_COLOR );
	REFRESH_GLOBAL( UT_CHEIGHT );
	REFRESH_GLOBAL( UT_ACTIVE );
	REFRESH_GLOBAL( UT_TIMEID );
	REFRESH_GLOBAL( SCALE );

	/* Verify Correct Timestamping */

	if ( TIME_COMPARE( esec, eusec, ssec, susec ) < 0 )
	{
		printf( "\nError: Timestamps Decreasing... Ignoring.\n\n" );
		fflush( stdout );

		return;
	}

	draw = ( !strcmp( CHAR_GLOBVAL( UT_ACTIVE ), "TRUE" )
		&& TRACE_STATUS != TRACE_FASTFWD );

	if ( !draw )
		NEEDS_REDRAW_UT = TRUE;

	ts = X_OF_TIME( ssec, susec, INT_GLOBVAL( SCALE ) );
	CK_X_TIME( ts, ssec, susec );

	te = X_OF_TIME( esec, eusec, INT_GLOBVAL( SCALE ) );
	CK_X_TIME( te, esec, eusec );

	HT = INT_GLOBVAL( UT_CHEIGHT );

	scale = INT_GLOBVAL( SCALE );

	/* Create First State */

	if ( UT_LIST == NULL )
	{
		U = UT_LIST = create_ut_state();

		for ( i=0 ; i < MAX_STATE ; i++ )
			U->counts[i] = 0;
		
		(U->counts[new])++;

		U->starttime.tv_sec = ssec;
		U->starttime.tv_usec = susec;

		U->endtime.tv_sec = esec;
		U->endtime.tv_usec = eusec;

		if ( draw )
			update_state_rects( U, scale, HT );
	}

	/* Insert State Change */

	else
	{
		/* Check Latest Existing State */

		cmpe = TIME_COMPARE( esec, eusec,
			UT_LIST->endtime.tv_sec, UT_LIST->endtime.tv_usec );

		/* Add Newer State */

		if ( cmpe > 0 )
		{
			if ( draw )
				update_state_rects( UT_LIST, scale, HT );

			Utmp = create_ut_state();

			for ( i=0 ; i < MAX_STATE ; i++ )
				Utmp->counts[i] = 0;

			(Utmp->counts[new])++;

			Utmp->endtime.tv_sec = esec;
			Utmp->endtime.tv_usec = eusec;

			/* Merge with Existing States */

			cmps = TIME_COMPARE( ssec, susec,
				UT_LIST->endtime.tv_sec, UT_LIST->endtime.tv_usec );

			/* Separate State, Add Intermediate Empty State */

			if ( cmps > 0 )
			{
				Utmp->starttime.tv_sec = ssec;
				Utmp->starttime.tv_usec = susec;

				if ( draw )
					update_state_rects( Utmp, scale, HT );

				/* Add Intermediate State */

				Utmp2 = Utmp->next = create_ut_state();

				for ( i=0 ; i < MAX_STATE ; i++ )
					Utmp2->counts[i] = 0;

				Utmp2->starttime.tv_sec = UT_LIST->endtime.tv_sec;
				Utmp2->starttime.tv_usec = UT_LIST->endtime.tv_usec;

				Utmp2->endtime.tv_sec = ssec;
				Utmp2->endtime.tv_usec = susec;

				/* Link Together */

				Utmp2->next = UT_LIST;

				UT_LIST = Utmp;

				return;
			}

			/* Adjacent State */

			else if ( cmps == 0 )
			{
				Utmp->starttime.tv_sec = ssec;
				Utmp->starttime.tv_usec = susec;

				if ( draw )
					update_state_rects( Utmp, scale, HT );

				Utmp->next = UT_LIST;

				UT_LIST = Utmp;

				return;
			}

			/* Overlaps Existing States */

			else
			{
				Utmp->starttime.tv_sec = UT_LIST->endtime.tv_sec;
				Utmp->starttime.tv_usec = UT_LIST->endtime.tv_usec;

				if ( draw )
					update_state_rects( Utmp, scale, HT );

				Utmp->next = U = UT_LIST;

				UT_LIST = Utmp;

				last = Utmp;
			}
		}

		/* Find Nearest Older State */

		else
		{
			U = UT_LIST;

			last = (UT_STATE) NULL;

			flag = 0;

			while ( U != NULL && !flag )
			{
				cmpe = TIME_COMPARE( esec, eusec,
					U->endtime.tv_sec, U->endtime.tv_usec );

				if ( cmpe >= 0 )
					flag++;

				else
				{
					last = U;

					U = U->next;
				}
			}

			/* Ran Off End, New State Earlier than Existing */

			if ( U == NULL )
			{
				/* Check for Overlap with Last State */

				cmpe = TIME_COMPARE( esec, eusec,
					last->starttime.tv_sec,
					last->starttime.tv_usec );

				/* Append New States Off End */

				if ( cmpe <= 0 )
				{
					/* Intermediate Empty State */

					if ( cmpe < 0 )
					{
						Utmp2 = last->next = create_ut_state();

						for ( i=0 ; i < MAX_STATE ; i++ )
							Utmp2->counts[i] = 0;

						Utmp2->starttime.tv_sec = esec;
						Utmp2->starttime.tv_usec = eusec;

						Utmp2->endtime.tv_sec =
							last->starttime.tv_sec;
						Utmp2->endtime.tv_usec =
							last->starttime.tv_usec;

						U = Utmp2;
					}

					else
						U = last;

					/* New State */

					Utmp = U->next = create_ut_state();

					for ( i=0 ; i < MAX_STATE ; i++ )
						Utmp->counts[i] = 0;

					(Utmp->counts[new])++;

					Utmp->starttime.tv_sec = ssec;
					Utmp->starttime.tv_usec = susec;

					Utmp->endtime.tv_sec = esec;
					Utmp->endtime.tv_usec = eusec;

					if ( draw )
						update_state_rects( Utmp, scale, HT );

					return;
				}

				/* Overlap with Last State - Split, But Wait for New */

				else
				{
					/* Adjust End of Old State */

					if ( draw && last->running != NULL )
					{
						X1_COORD( last->running ) = te;

						SET_COORDS( interp, UT_C, last->running );
					}

					if ( draw && last->system != NULL )
					{
						X1_COORD( last->system ) = te;

						SET_COORDS( interp, UT_C, last->system );
					}

					if ( draw && last->idle != NULL )
					{
						X1_COORD( last->idle ) = te;

						SET_COORDS( interp, UT_C, last->idle );
					}

					/* Create New State */

					Utmp = create_ut_state();

					for ( i=0 ; i < MAX_STATE ; i++ )
						Utmp->counts[i] = last->counts[i];

					/* Don't Increment New Yet - Defer */

					Utmp->starttime.tv_sec = last->starttime.tv_sec;
					Utmp->starttime.tv_usec = last->starttime.tv_usec;

					Utmp->endtime.tv_sec = esec;
					Utmp->endtime.tv_usec = eusec;

					if ( draw )
						update_state_rects( Utmp, scale, HT );

					/* Set Original State Start Time */

					last->starttime.tv_sec = esec;
					last->starttime.tv_usec = eusec;

					/* Add New State to List */

					U = last->next = Utmp;
				}
			}

			/* Defer Aligned State for Start Handling Below */
			/* cmpe == 0 */

			/* Split State */

			else if ( cmpe > 0 )
			{
				/* Adjust End of Old State */

				if ( draw && last->running != NULL )
				{
					X1_COORD( last->running ) = te;

					SET_COORDS( interp, UT_C, last->running );
				}

				if ( draw && last->system != NULL )
				{
					X1_COORD( last->system ) = te;

					SET_COORDS( interp, UT_C, last->system );
				}

				if ( draw && last->idle != NULL )
				{
					X1_COORD( last->idle ) = te;

					SET_COORDS( interp, UT_C, last->idle );
				}

				/* Create New State */

				Utmp = create_ut_state();

				for ( i=0 ; i < MAX_STATE ; i++ )
					Utmp->counts[i] = last->counts[i];

				/* Don't Increment New Yet - Defer */

				Utmp->starttime.tv_sec = last->starttime.tv_sec;
				Utmp->starttime.tv_usec = last->starttime.tv_usec;

				Utmp->endtime.tv_sec = esec;
				Utmp->endtime.tv_usec = eusec;

				if ( draw )
					update_state_rects( Utmp, scale, HT );

				/* Set Original State Start Time */

				last->starttime.tv_sec = esec;
				last->starttime.tv_usec = eusec;

				/* Add New State to List */

				Utmp->next = U;

				last->next = Utmp;

				U = Utmp;
			}
		}

		/* Adjust Task Counts Backwards */

		flag = 0;

		while ( U != NULL && !flag )
		{
			cmps = TIME_COMPARE( ssec, susec,
				U->starttime.tv_sec, U->starttime.tv_usec );

			if ( cmps >= 0 )
				flag++;
			
			else
			{
				/* Update Counts */

				(U->counts[new])++;

				if ( draw )
					update_state_rects( U, scale, HT );

				last = U;

				U = U->next;
			}
		}

		if ( U == NULL )
		{
			/* Create New Earliest State */

			Utmp = create_ut_state();

			for ( i=0 ; i < MAX_STATE ; i++ )
				Utmp->counts[i] = 0;

			(Utmp->counts[new])++;

			Utmp->starttime.tv_sec = ssec;
			Utmp->starttime.tv_usec = susec;

			Utmp->endtime.tv_sec = last->starttime.tv_sec;
			Utmp->endtime.tv_usec = last->starttime.tv_usec;

			if ( draw )
				update_state_rects( Utmp, scale, HT );

			last->next = Utmp;

			return;
		}

		/* Fix Beginning of New State */

		/* Aligned State, Simply Update Counts */

		if ( cmps == 0 )
		{
			(U->counts[new])++;

			if ( draw )
				update_state_rects( U, scale, HT );
		}

		/* Check for Start Split (Non-Aligned with State End) */

		else
		{
			cmps = TIME_COMPARE( ssec, susec,
				U->endtime.tv_sec, U->endtime.tv_usec );

			/* Split Into New States */

			if ( cmps < 0 )
			{
				/* Adjust End of Old State */

				if ( draw && U->running != NULL )
				{
					X2_COORD( U->running ) = ts;

					SET_COORDS( interp, UT_C, U->running );
				}

				if ( draw && U->system != NULL )
				{
					X2_COORD( U->system ) = ts;

					SET_COORDS( interp, UT_C, U->system );
				}

				if ( draw && U->idle != NULL )
				{
					X2_COORD( U->idle ) = ts;

					SET_COORDS( interp, UT_C, U->idle );
				}

				/* Create New State */

				Utmp = create_ut_state();

				for ( i=0 ; i < MAX_STATE ; i++ )
					Utmp->counts[i] = U->counts[i];

				(Utmp->counts[new])++;

				Utmp->starttime.tv_sec = ssec;
				Utmp->starttime.tv_usec = susec;

				Utmp->endtime.tv_sec = U->endtime.tv_sec;
				Utmp->endtime.tv_usec = U->endtime.tv_usec;

				if ( draw )
					update_state_rects( Utmp, scale, HT );

				/* Set Original State End Time */

				U->endtime.tv_sec = ssec;
				U->endtime.tv_usec = susec;

				/* Add New State to List */

				Utmp->next = U;

				if ( last != NULL )
					last->next = Utmp;

				else
					UT_LIST = Utmp;
			}
		}
	}

	sprintf( cmd, "%s raise %d", UT_C, INT_GLOBVAL( UT_TIMEID ) );

	Tcl_Eval( interp, cmd );
}


void
update_state_rects( U, scale, ht )
UT_STATE U;
int scale;
int ht;
{
	int ry, sy, iy;
	int x1, x2;

	x1 = X_OF_TIME( U->starttime.tv_sec, U->starttime.tv_usec, scale );

	CK_X_TIME( x1, U->starttime.tv_sec, U->starttime.tv_usec );

	x2 = X_OF_TIME( U->endtime.tv_sec, U->endtime.tv_usec, scale );

	CK_X_TIME( x2, U->endtime.tv_sec, U->endtime.tv_usec );

	/* Verify Rectangles Worth Drawing */

	if ( x1 == x2 )
	{
		if ( U->running != NULL )
		{
			DELETE_GOBJ( interp, UT_C, U->running );
		}

		if ( U->system != NULL )
		{
			DELETE_GOBJ( interp, UT_C, U->system );
		}

		if ( U->idle != NULL )
		{
			DELETE_GOBJ( interp, UT_C, U->idle );
		}

		return;
	}

	/* Get Vertical Coords */

	calcUtilCoords( U->counts, ht, &ry, &sy, &iy );

	/* Check Running Rectangle */

	if ( U->running != NULL )
	{
		if ( ry != ht )
		{
			X1_COORD( U->running ) = x1;
			X2_COORD( U->running ) = x2;

			Y1_COORD( U->running ) = ry;
			Y2_COORD( U->running ) = ht;

			SET_COORDS( interp, UT_C, U->running );
		}

		else
		{
			DELETE_GOBJ( interp, UT_C, U->running );
		}
	}

	else if ( ry != ht )
	{
		CREATE_RECT( interp, UT_C, U->running,
			x1, ry, x2, ht,
			CHAR_GLOBVAL( UT_RUNNING_COLOR ), "" );
	}

	/* Check System Rectangle */

	if ( U->system != NULL )
	{
		if ( sy != ry )
		{
			X1_COORD( U->system ) = x1;
			X2_COORD( U->system ) = x2;

			Y1_COORD( U->system ) = sy;
			Y2_COORD( U->system ) = ry;

			SET_COORDS( interp, UT_C, U->system );
		}

		else
		{
			DELETE_GOBJ( interp, UT_C, U->system );
		}
	}

	else if ( sy != ry )
	{
		CREATE_RECT( interp, UT_C, U->system,
			x1, sy, x2, ry,
			CHAR_GLOBVAL( UT_SYSTEM_COLOR ), "" );
	}

	/* Check Idle Rectangle */

	if ( U->idle != NULL )
	{
		if ( iy != sy )
		{
			X1_COORD( U->idle ) = x1;
			X2_COORD( U->idle ) = x2;

			Y1_COORD( U->idle ) = iy;
			Y2_COORD( U->idle ) = sy;

			SET_COORDS( interp, UT_C, U->idle );
		}

		else
		{
			DELETE_GOBJ( interp, UT_C, U->idle );
		}
	}

	else if ( iy != sy )
	{
		CREATE_RECT( interp, UT_C, U->idle,
			x1, iy, x2, sy,
			CHAR_GLOBVAL( UT_IDLE_COLOR ), "" );
	}
}


void
calcUtilCoords( counts, ht, ry, sy, iy )
int *counts;
int ht;
int *ry;
int *sy;
int *iy;
{
	char cmd[1024];

	int rcnt, scnt, icnt;
	int tot;

	rcnt = counts[STATE_RUNNING];
	scnt = counts[STATE_SYSTEM];
	icnt = counts[STATE_IDLE];

	/* Check Max Ntasks */

	tot = rcnt + scnt + icnt;

	if ( tot > UT_MAX_NTASKS )
	{
		UT_MAX_NTASKS = tot;

		sprintf( cmd, "%s.ntasks configure -text {%d}", UT_F, tot );

		Tcl_Eval( interp, cmd );

		Tcl_Eval( interp, "utAdjustHeight" );
	}

	/* Calculate Coords */

	*iy = ht - ( ht * tot / UT_MAX_NTASKS );

	*sy = ht - ( ht * ( rcnt + scnt ) / UT_MAX_NTASKS );

	*ry = ht - ( ht * rcnt / UT_MAX_NTASKS );
}


int
utIncr( sec, usec )
int sec;
int usec;
{
	UT_STATE U;

	int tx;

	REFRESH_GLOBAL( TIMEX );

	U = UT_LIST;

	if ( U == NULL )
		return( TCL_OK );

	tx = INT_GLOBVAL( TIMEX );

	if ( U->running != NULL )
	{
		X2_COORD( U->running ) = tx;

		SET_COORDS( interp, UT_C, U->running );
	}

	if ( U->system != NULL )
	{
		X2_COORD( U->system ) = tx;

		SET_COORDS( interp, UT_C, U->system );
	}

	if ( U->idle != NULL )
	{
		X2_COORD( U->idle ) = tx;

		SET_COORDS( interp, UT_C, U->idle );
	}

	return( TCL_OK );
}


/* ARGSUSED */
int
ut_adjust_height_proc( clientData, itp, argc, argv )
ClientData clientData;
Tcl_Interp *itp;
int argc;
char **argv;
{
	UT_STATE U;

	int ry, sy, iy;
	int ht;

	REFRESH_GLOBAL( UT_CHEIGHT );

	ht = INT_GLOBVAL( UT_CHEIGHT );

	U = UT_LIST;

	while ( U != NULL )
	{
		calcUtilCoords( U->counts, ht, &ry, &sy, &iy );

		if ( U->running != NULL )
		{
			Y1_COORD( U->running ) = ry;
			Y2_COORD( U->running ) = ht;

			SET_COORDS( itp, UT_C, U->running );
		}

		if ( U->system != NULL )
		{
			Y1_COORD( U->system ) = sy;
			Y2_COORD( U->system ) = ry;

			SET_COORDS( itp, UT_C, U->system );
		}

		if ( U->idle != NULL )
		{
			Y1_COORD( U->idle ) = iy;
			Y2_COORD( U->idle ) = sy;

			SET_COORDS( itp, UT_C, U->idle );
		}

		U = U->next;
	}

	return( TCL_OK );
}


/* ARGSUSED */
int
ut_zoom_proc( clientData, itp, argc, argv )
ClientData clientData;
Tcl_Interp *itp;
int argc;
char **argv;
{
	UT_STATE U;

	int x1, x2;
	int scale;
	int ht;

	REFRESH_GLOBAL( UT_CHEIGHT );

	ht = INT_GLOBVAL( UT_CHEIGHT );

	scale = atoi( argv[1] );

	U = UT_LIST;

	while ( U != NULL )
	{
		update_state_rects( U, scale, ht );

		U = U->next;
	}

	return( TCL_OK );
}


void
redraw_utilization()
{
	REFRESH_GLOBAL( UT_ACTIVE );

	if ( !strcmp( CHAR_GLOBVAL( UT_ACTIVE ), "TRUE" ) )
		Tcl_Eval( interp, "utUpdate" );
}


/* ARGSUSED */
int
ut_update_proc( clientData, itp, argc, argv )
ClientData clientData;
Tcl_Interp *itp;
int argc;
char **argv;
{
	UT_STATE U;

	int HT;

	int scale;
	int save;

	if ( NEEDS_REDRAW_UT )
	{
		LOCK_INTERFACE( save );

		Tcl_Eval( itp,
			"setMsg { Drawing Views... Utilization... }" );

		REFRESH_GLOBAL( UT_CHEIGHT );
		REFRESH_GLOBAL( SCALE );

		HT = INT_GLOBVAL( UT_CHEIGHT );

		scale = INT_GLOBVAL( SCALE );

		U = UT_LIST;

		while ( U != NULL )
		{
			update_state_rects( U, scale, HT );

			U = U->next;
		}

		Tcl_Eval( itp,
			"setMsg { Drawing Views... Utilization... Done. }" );

		NEEDS_REDRAW_UT = FALSE;

		UNLOCK_INTERFACE( save );
	}

	return( TCL_OK );
}


/* ARGSUSED */
int
ut_reset_proc( clientData, itp, argc, argv )
ClientData clientData;
Tcl_Interp *itp;
int argc;
char **argv;
{
	UT_STATE U;

	char cmd[1024];

	REFRESH_GLOBAL( FRAME_BORDER );
	REFRESH_GLOBAL( FRAME_OFFSET );

	U = UT_LIST;

	while ( U != NULL )
	{
		if ( U->running != NULL )
			DELETE_GOBJ( itp, UT_C, U->running );

		if ( U->system != NULL )
			DELETE_GOBJ( itp, UT_C, U->system );

		if ( U->idle != NULL )
			DELETE_GOBJ( itp, UT_C, U->idle );

		U = U->next;
	}

	UT_SCROLL_MARK = 0;

	UT_MAX_NTASKS = 1;

	sprintf( cmd, "%s.ntasks configure -text {%d}",
		UT_F, UT_MAX_NTASKS );

	Tcl_Eval( itp, cmd );

	return( TCL_OK );
}