top: avoid %cpu distortions when toggling task/thread modes
This commit addresses a long standing buglet (debian #441166) which surfaces when the display mode is switched between task and threads. An extra procps refresh is now forced upon such a transition which parallels the approach used at startup for the exact same reason. Reference: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441166
This commit is contained in:
		
							
								
								
									
										10
									
								
								top/top.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								top/top.c
									
									
									
									
									
								
							| @@ -138,7 +138,7 @@ static int   Cap_can_goto = 0; | |||||||
|            The Stdout_buf is transparent to our code and regardless of whose |            The Stdout_buf is transparent to our code and regardless of whose | ||||||
|            buffer is used, stdout is flushed at frame end or if interactive. */ |            buffer is used, stdout is flushed at frame end or if interactive. */ | ||||||
| static char  *Pseudo_screen; | static char  *Pseudo_screen; | ||||||
| static int    Pseudo_row = -1; | static int    Pseudo_row = PROC_XTRA; | ||||||
| static size_t Pseudo_size; | static size_t Pseudo_size; | ||||||
| #ifndef OFF_STDIOLBF | #ifndef OFF_STDIOLBF | ||||||
|         // less than stdout's normal buffer but with luck mostly '\n' anyway |         // less than stdout's normal buffer but with luck mostly '\n' anyway | ||||||
| @@ -2793,6 +2793,8 @@ static void keys_global (int ch) { | |||||||
|          if (!CHKw(w, View_STATES)) |          if (!CHKw(w, View_STATES)) | ||||||
|             show_msg(fmtmk(N_fmt(THREADS_show_fmt) |             show_msg(fmtmk(N_fmt(THREADS_show_fmt) | ||||||
|                , Thread_mode ? N_txt(ON_word_only_txt) : N_txt(OFF_one_word_txt))); |                , Thread_mode ? N_txt(ON_word_only_txt) : N_txt(OFF_one_word_txt))); | ||||||
|  |          // force an extra procs refresh to avoid %cpu distortions... | ||||||
|  |          Pseudo_row = PROC_XTRA; | ||||||
|          break; |          break; | ||||||
|       case 'I': |       case 'I': | ||||||
|          if (Cpu_tot > 1) { |          if (Cpu_tot > 1) { | ||||||
| @@ -3717,11 +3719,11 @@ static void frame_make (void) { | |||||||
|    if (Frames_paused) pause_pgm(); |    if (Frames_paused) pause_pgm(); | ||||||
|    if (Frames_resize) zap_fieldstab(); |    if (Frames_resize) zap_fieldstab(); | ||||||
|  |  | ||||||
|    // whoa first time, gotta' prime the pump... |    // whoa either first time or thread/task mode change, (re)prime the pump... | ||||||
|    if (-1 == Pseudo_row) { |    if (Pseudo_row == PROC_XTRA) { | ||||||
|       procs_refresh(); |       procs_refresh(); | ||||||
|       putp(Cap_clr_scr); |  | ||||||
|       usleep(LIB_USLEEP); |       usleep(LIB_USLEEP); | ||||||
|  |       putp(Cap_clr_scr); | ||||||
|    } else |    } else | ||||||
|       putp(Batch ? "\n\n" : Cap_home); |       putp(Batch ? "\n\n" : Cap_home); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -127,6 +127,10 @@ | |||||||
| #define kbd_INS    '\x8a' | #define kbd_INS    '\x8a' | ||||||
| #define kbd_DEL    '\x8b' | #define kbd_DEL    '\x8b' | ||||||
|  |  | ||||||
|  |         /* Special value in Pseudo_row to force an additional procs refresh | ||||||
|  |            -- used at startup and for task/thread mode transitions */ | ||||||
|  | #define PROC_XTRA  -1 | ||||||
|  |  | ||||||
|  |  | ||||||
| /* #####  Enum's and Typedef's  ############################################ */ | /* #####  Enum's and Typedef's  ############################################ */ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user