From 410615e73b1d016a6910a0a677b9d3ec7e7623d1 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Sat, 15 Oct 2022 14:54:36 -0700 Subject: [PATCH] Checkpoint, build 321 I think --- emu/cpuid.h | 1 + fs/fake.c | 4 +-- fs/proc/ish.c | 9 +++--- .../xcshareddata/xcschemes/iSH.xcscheme | 32 +++++++++++++++++++ kernel/calls.c | 1 + kernel/exit.c | 17 ++++++---- kernel/resource.c | 7 ++++ kernel/resource.h | 1 + util/sync.h | 14 +++----- 9 files changed, 64 insertions(+), 22 deletions(-) diff --git a/emu/cpuid.h b/emu/cpuid.h index b2222e0976..a314e2fc63 100644 --- a/emu/cpuid.h +++ b/emu/cpuid.h @@ -20,6 +20,7 @@ static inline void do_cpuid(dword_t *eax, dword_t *ebx, dword_t *ecx, dword_t *e *edx = (1 << 0) // fpu | (1 << 15) // cmov | (1 << 23) // mmx + | (1 << 25) // sse | (1 << 26) // sse2 ; break; diff --git a/fs/fake.c b/fs/fake.c index 95a32cf7eb..f3b1ce688d 100644 --- a/fs/fake.c +++ b/fs/fake.c @@ -356,10 +356,10 @@ static void __attribute__((constructor)) init_fake_fdops() { static int fakefs_mount(struct mount *mount) { char db_path[PATH_MAX]; - strcpy(db_path, mount->source); + strncpy(db_path, mount->source, PATH_MAX -1); char *basename = strrchr(db_path, '/') + 1; assert(strcmp(basename, "data") == 0); - strcpy(basename, "meta.db"); + strncpy(basename, "meta.db", 8); // do this now so rebuilding can use root_fd int err = realfs.mount(mount); diff --git a/fs/proc/ish.c b/fs/proc/ish.c index d7dcf0ae68..0b9ba5d0e1 100644 --- a/fs/proc/ish.c +++ b/fs/proc/ish.c @@ -278,18 +278,18 @@ static int proc_ish_show_ips(struct proc_entry *UNUSED(entry), struct proc_data char * int_ip = malloc(100); char * int_dstaddr = malloc(100); if(cursor->ifa_addr->sa_family == AF_INET) { - strcpy(type, "IF_INET"); + strncpy(type, "IF_INET", 9); } else { - strcpy(type, "IF_INET6"); + strncpy(type, "IF_INET6", 9); } //cursor->ifa_addr->sa_family = AF_INET; get_ip_str(cursor->ifa_addr, int_ip, 100); char * mac = malloc(100); if(cursor->ifa_dstaddr != NULL) { if(cursor->ifa_dstaddr->sa_family == AF_INET) { - strcpy(type, "IF_INET"); + strncpy(type, "IF_INET", 9); } else { - strcpy(type, "IF_INET6"); + strncpy(type, "IF_INET6", 9); cursor->ifa_dstaddr->sa_family = AF_INET6; } get_ip_str(cursor->ifa_dstaddr, int_dstaddr, 100); @@ -315,6 +315,7 @@ static int proc_ish_show_ips(struct proc_entry *UNUSED(entry), struct proc_data ); free(int_ip); free(int_flags); + free(int_dstaddr); } cursor = cursor->ifa_next; } diff --git a/iSH-AOK.xcodeproj/xcshareddata/xcschemes/iSH.xcscheme b/iSH-AOK.xcodeproj/xcshareddata/xcschemes/iSH.xcscheme index ce9c0adaff..47a5512eee 100644 --- a/iSH-AOK.xcodeproj/xcshareddata/xcschemes/iSH.xcscheme +++ b/iSH-AOK.xcodeproj/xcshareddata/xcschemes/iSH.xcscheme @@ -111,6 +111,38 @@ ReferencedContainer = "container:iSH-AOK.xcodeproj"> + + + + + + + + + + + + + + death_lock); - // if(!lock(current->death_lock)) - // return; // Task is already in the process of being deleted, most likely by do_exit(). -mke + // pthread_mutex_lock(¤t->death_lock); + if(!pthread_mutex_trylock(¤t->death_lock)) { + goto EXIT; + } else { + //nanosleep(&lock_pause, NULL); // Stupid place holder + } current->exiting = true; @@ -151,8 +154,8 @@ noreturn void do_exit(int status) { send_signal(parent, leader->exit_signal, info); } - if (exit_hook != NULL) - exit_hook(current, status); + //if (exit_hook != NULL) + // exit_hook(current, status); } modify_critical_region_counter(current, -1, __FILE__, __LINE__); @@ -163,7 +166,7 @@ noreturn void do_exit(int status) { unlock(&pids_lock); //atomic_l_unlockf(); - pthread_exit(NULL); +EXIT:pthread_exit(NULL); } noreturn void do_exit_group(int status) { @@ -198,9 +201,9 @@ noreturn void do_exit_group(int status) { notify(&task->group->stopped_cond); } - unlock(&group->lock); unlock(&pids_lock); modify_critical_region_counter(current, -1, __FILE__, __LINE__); + unlock(&group->lock); do_exit(status); } diff --git a/kernel/resource.c b/kernel/resource.c index 42b1bb9513..529c5c334e 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -260,6 +260,13 @@ int_t sys_sched_get_priority_max(int_t policy) { return _EINVAL; } +int_t sys_sched_get_priority_min(int_t policy) { + STRACE("sched_get_priority_min(%d)", policy); + if (policy == 0) + return 0; + return _EINVAL; +} + int_t sys_ioprio_get(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio)) { return 0; } diff --git a/kernel/resource.h b/kernel/resource.h index 55f2b1e0b4..26b56fe9b4 100644 --- a/kernel/resource.h +++ b/kernel/resource.h @@ -75,6 +75,7 @@ int_t sys_sched_getparam(pid_t_ pid, addr_t param_addr); int_t sys_sched_getscheduler(pid_t_ UNUSED(pid)); int_t sys_sched_setscheduler(pid_t_ UNUSED(pid), int_t policy, addr_t param_addr); int_t sys_sched_get_priority_max(int_t policy); +int_t sys_sched_get_priority_min(int_t policy); int_t sys_ioprio_set(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio)); int_t sys_ioprio_get(int_t UNUSED(which), int_t UNUSED(who), int_t UNUSED(ioprio)); diff --git a/util/sync.h b/util/sync.h index 10141cf860..d9e39bb890 100644 --- a/util/sync.h +++ b/util/sync.h @@ -322,7 +322,7 @@ static inline void _read_unlock(wrlock_t *lock, __attribute__((unused)) const ch printk("ERROR: read_unlock(%x) error(PID: %d Process: %s count %d) (%s:%d)\n",lock, current_pid(), current_comm(), lock->val, file, line); lock->val = 0; lock->pid = -1; - strcpy(lock->comm, ""); + strncpy(lock->comm, "", 1); modify_locks_held_count_wrapper(-1); //modify_critical_region_counter_wrapper(-1, __FILE__, __LINE__); //STRACE("read_unlock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line); @@ -362,7 +362,7 @@ static inline void _write_unlock(wrlock_t *lock, __attribute__((unused)) const c //assert(lock->val == -1); lock->val = lock->line = lock->pid = 0; lock->pid = -1; - strcpy(lock->comm, ""); + strncpy(lock->comm, "", 1); //STRACE("write_unlock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line); lock->file = NULL; modify_locks_held_count_wrapper(-1); @@ -392,10 +392,8 @@ static inline void __write_lock(wrlock_t *lock, const char *file, int line) { // lock->file = file; lock->line = line; lock->pid = current_pid(); - char *IhateC = malloc(16); - IhateC = current_comm(); - if(lock->pid > 9) - strncpy((char *)lock->comm, IhateC, 16); + if(lock->pid > 9) + strncpy((char *)lock->comm, current_comm(), 16); //STRACE("write_lock(%x, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line); //modify_critical_region_counter_wrapper(-1,__FILE__, __LINE__); } @@ -560,10 +558,8 @@ static inline void _read_lock(wrlock_t *lock, __attribute__((unused)) const char } lock->pid = current_pid(); - char *IhateC = malloc(16); - IhateC = current_comm(); if(lock->pid > 9) - strncpy((char *)lock->comm, IhateC, 16); + strncpy((char *)lock->comm, current_comm(), 16); //strncpy(lock->comm, current_comm(), 16); modify_critical_region_counter_wrapper(-1, __FILE__, __LINE__); //STRACE("read_lock(%d, %s(%d), %s, %d\n", lock, lock->comm, lock->pid, file, line);