Call monitor thread from os thread.

This commit is contained in:
Ivan Baravy 2020-05-09 07:34:28 +03:00
parent 90d1aaaccc
commit 7f355dfed2
3 changed files with 37 additions and 4 deletions

View File

@ -22,6 +22,7 @@ public sha3_256_oneshot as 'hash_oneshot'
public kos_time_to_epoch
public kos_init
public monitor_thread
public CURRENT_TASK as 'kos_current_task'
public current_slot as 'kos_current_slot'
public TASK_COUNT as 'kos_task_count'
@ -360,6 +361,8 @@ proc umka_os uses ebx esi edi
mov dword[TASK_COUNT], 6
stdcall umka_install_thread, [monitor_thread]
ccall raise, SIGPROF
jmp osloop
@ -425,6 +428,25 @@ change_task:
mov [REDRAW_BACKGROUND], 0
ret
public umka_install_thread
proc umka_install_thread _func
stdcall kernel_alloc, RING0_STACK_SIZE
mov ebx, eax
; mov edx, SLOT_BASE+256*6
mov edx, [TASK_COUNT]
shl edx, 8
add edx, SLOT_BASE
call setup_os_slot
mov dword [edx], 'USER'
sub [edx+APPDATA.saved_esp], 4
mov eax, [edx+APPDATA.saved_esp]
mov ecx, [_func]
mov dword[eax], ecx
xor ecx, ecx
call sched_add_thread
inc dword[TASK_COUNT]
ret
endp
sysfn_saveramdisk:
sysfn_meminfo:
@ -551,6 +573,7 @@ task_base_addr dd TASK_BASE
task_data_addr dd TASK_DATA
slot_base_addr dd SLOT_BASE
monitor_thread dd ?
win_stack_addr dd WIN_STACK
win_pos_addr dd WIN_POS

4
umka.h
View File

@ -317,7 +317,7 @@ typedef struct {
} arp_entry_t;
void umka_os(void);
//void umka_idle(void);
void umka_install_thread(void *func) __attribute__((__stdcall__));
void kos_init(void);
void i40(void);
uint32_t kos_time_to_epoch(uint32_t *time);
@ -460,7 +460,7 @@ extern size_t kos_task_count;
extern void *kos_task_base;
extern void *kos_task_data;
extern appdata_t *kos_slot_base;
extern void (*monitor_thread)(void);
extern uint32_t *kos_lfb_base;
extern uint16_t *kos_win_stack;
extern uint16_t *kos_win_pos;

View File

@ -32,6 +32,14 @@ void scheduler(int signo, siginfo_t *info, void *context) {
}
}
void monitor() {
while (1) {
for (int i = 0; i < 10000000; i++) {}
printf("6 usera\n");
}
}
int main() {
struct sigaction sa;
@ -44,6 +52,8 @@ int main() {
return 1;
}
monitor_thread = monitor;
umka_os();
return 0;