@@ -41,16 +41,16 @@ uint64_t calc_heap(uintptr_t ptr){
4141char * procname ;
4242
4343void print_process_info (){
44- process_t * processes = get_all_processes ();
45- for (int i = 0 ; i < MAX_PROCS ; i ++ ){
46- process_t * proc = & processes [i ];
44+ process_t * proc = get_all_processes ();
45+ while (proc ){
4746 if (proc -> id != 0 && proc -> state != STOPPED && (!procname || strcmp_case (procname ,proc -> name ,true) == 0 )){
48- print ("Process [%i]: % s [pid = %i | status = %s]" , i ,(uintptr_t )proc -> name ,proc -> id ,(uintptr_t )parse_proc_state (proc -> state ));
47+ print ("Process % s [pid = %i | status = %s]" ,(uintptr_t )proc -> name ,proc -> id ,(uintptr_t )parse_proc_state (proc -> state ));
4948 print ("Stack: %x (%x). SP: %x" ,proc -> stack , proc -> stack_size , proc -> sp );
5049 print ("Heap: %x (%x)" ,proc -> mm .mmap_bottom , calc_heap (proc -> heap_phys ));
5150 print ("Flags: %x" , proc -> spsr );
5251 print ("PC: %x" ,proc -> pc );
5352 }
53+ proc = proc -> process_next ;
5454 }
5555}
5656
@@ -79,7 +79,6 @@ void draw_memory(char *name,int x, int y, int width, int full_height, int used,
7979
8080void draw_process_view (){
8181 fb_clear (& ctx ,system_theme .bg_color + 0x112211 );
82- process_t * processes = get_all_processes ();
8382 gpu_size screen_size = (gpu_size ){ctx .width ,ctx .height };
8483 gpu_point screen_middle = {screen_size .width / 2 , screen_size .height / 2 };
8584
@@ -90,26 +89,25 @@ void draw_process_view(){
9089 if (ev .key == KEY_LEFT )
9190 scroll_index = max (scroll_index - 1 , 0 );
9291 if (ev .key == KEY_RIGHT )
93- scroll_index = min ( scroll_index + 1 , MAX_PROCS ) ;
92+ scroll_index ++ ;
9493 }
9594
9695 for (int i = 0 ; i < PROCS_PER_SCREEN ; i ++ ) {
97- int index = scroll_index ;
98- int valid_count = 0 ;
96+ uint16_t index = scroll_index + i ;
97+ uint16_t valid_count = 0 ;
98+ process_t * proc = get_all_processes ();
9999
100- process_t * proc = NULL ;
101- while (index < MAX_PROCS ) {
102- proc = & processes [index ];
100+ while (proc ) {
103101 if (proc -> id != 0 && proc -> state != STOPPED ) {
104- if (valid_count == i + scroll_index ) {
102+ if (valid_count == index ) {
105103 break ;
106104 }
107105 valid_count ++ ;
108106 }
109- index ++ ;
107+ proc = proc -> process_next ;
110108 }
111109
112- if (proc == NULL || proc -> id == 0 || valid_count < i || proc -> state == STOPPED ) break ;
110+ if (proc == NULL || proc -> id == 0 || proc -> state == STOPPED ) break ;
113111
114112 string name = string_from_literal ((const char * )(uintptr_t )proc -> name );
115113 string state = string_from_literal (parse_proc_state (proc -> state ));
0 commit comments