@@ -27,7 +27,7 @@ proc_info_p procs[PROC_MAX] = {
2727proc_info_p current = & kernel_process_info ;
2828
2929void proc_switch (void * arg ) {
30- cpu_state_p state = (cpu_state_p )arg ;
30+ // cpu_state_p state = (cpu_state_p)arg;
3131 // serial_printf("states: rax: %lx - rbx: %lx - rcx: %lx - rdx: %lx - rsi: %lx\n", state->rax, state->rbx, state->rcx, state->rdx, state->rsi);
3232 // serial_printf("states: rdi: %lx - rsp: %lx - r8: %lx - r9: %lx - r10: %lx\n", state->rdi, state->rsp, state->r8, state->r9, state->r10);
3333 // serial_printf("states: r11: %lx\n", state->r11);
@@ -38,15 +38,12 @@ void proc_switch(void* arg) {
3838 // serial_printf("states: cr3: %lx\n", state->cr3);
3939 // serial_printf("states: rbp: %lx\n", state->rbp);
4040 // serial_printf("states: ss: %lx\n", state->ss);
41- serial_line ("" );
42-
43- // serial_printf("proc_switch: Current process %s\n", current->name);
41+ serial_printf ("proc_switch: Current process %s\n" , current -> name );
4442 // memcpy(current->cpu_state, state, sizeof(cpu_state_t));
45- /*
43+
4644 current -> state = PROC_STATE_READY ;
47- serial_line("");
4845 current = current -> next ;
49- serial_line("");
46+ /*
5047 if(current->state == PROC_STATE_NEW) {
5148 serial_line("");
5249 current->state = PROC_STATE_READY;
@@ -70,26 +67,42 @@ void proc_switch(void* arg) {
7067 // (current->entrypoint)(current->arguments);
7168 // serial_line("");
7269 }
73- serial_line("");
74- serial_printf("proc_switch: Switching to process %s\n", current->name);
7570 */
71+ serial_printf ("proc_switch: Switching to process %s\n" , current -> name );
7672}
7773
78- void proc_create (proc_info_p proc , void (* entrypoint )(void * ), void * arg ) {
79- proc -> children = NULL ;
74+ void proc_create (proc_info_p proc , const char * name , void (* entrypoint )(void * ), void * arg ) {
75+ serial_line ("" );
76+ memcpy (proc -> name , name , 32 );
77+ serial_line ("" );
78+ * proc -> children = NULL ;
79+ serial_line ("" );
8080 proc -> children_count = 0 ;
81- proc -> cpu_state = (cpu_state_t * )kmalloc (sizeof (cpu_state_t ));
81+ serial_line ("" );
82+ void * foo = kmalloc (sizeof (cpu_state_t ));
83+ serial_printf ("foo: %p\n" , foo );
84+ proc -> cpu_state = (cpu_state_p )foo ;
85+ serial_line ("" );
8286 proc -> parent = current ;
87+ serial_line ("" );
8388 proc -> pid = last_pid ++ ;
89+ serial_line ("" );
8490 proc -> priority = PROC_PRIO_NORMAL ;
91+ serial_line ("" );
8592 proc -> stack = kmalloc (PROC_STACK_SIZE );
93+ serial_line ("" );
8694 proc -> state = PROC_STATE_NEW ;
95+ serial_line ("" );
8796 proc -> entrypoint = entrypoint ;
97+ serial_line ("" );
8898 proc -> arguments = arg ;
99+ serial_line ("" );
89100}
90101
91102void proc_execute (proc_info_p proc ) {
103+ serial_line ("" );
92104 proc -> next = current -> next ;
105+ serial_line ("" );
93106 current -> next = proc ;
94107
95108 serial_printf ("proc_execute: Executing process %s\n" , proc -> name );
0 commit comments