diff options
| author | Jake Mannens <jake72360@gmail.com> | 2018-07-25 01:17:39 +1000 |
|---|---|---|
| committer | Jake Mannens <jake72360@gmail.com> | 2018-07-25 01:17:39 +1000 |
| commit | 45819c035d0b92275de68e559f066cbe50996926 (patch) | |
| tree | 0ae32cffc4567dee891ecca9e5162731b341d1a0 /include/kernel/sched.h | |
| parent | a0aa45ea6f4027dd4080cf1456a2fc5d9e94f87b (diff) | |
Fixed a bug in switch_to() in which the value of EBX was not popped
prior to return. This meant that switching to the same task did not
abort properly as the incorrect return address was popped off the stack.
Fixed a bug where the task register was not initialized before the
scheduler. This meant that on the first task switch, the CPU would dump
it's current state to a random address (0 most likely), potentially
corrupting important data. This has been corrected by introducing a
'garbage TSS' (and associated descriptor in the GDT) which is selected
before the scheduler is initialized as a safe place for the data to be
written.
Modified the scheduler so that it now waits indefinitely until a task
becomes ready to run. This fixes the possible bug where the scheduler
won't re-schedule the currently running task if it is the only task on
the system.
Add signal handling capabilities to the kernel. The bulk of this is
present in the subroutine check_signals() defined in traps.s. This
function is called on every timer tick and system call prior to
userspace return. The subroutine operates by pushing fake state
information onto the kernel's stack, then using it to return to
userspace. Prior to this, the subroutine pushes the return address
0xFFFFE000 onto the user's stack. This address corresponds to the
unmapped page located between the top of the user's stack (lower) and
the kernel's stack page (upper). When the user's signal handler tries to
return, it will cause a page fault that will be used as a notification
mechanism to inform the kernel that the signal handler is done. The
kernel will then switch to the originally pushed state information and
use it to return the task to the original execution state. Due to it's
nature, check_signals() must only be called prior to exiting the kernel
since it may not return.
Added the header file 'signal.h' which defines (most) of the POSIX
signals as well as the prototype for the signal() function.
Added the 'signal' element to the task structure. This field is a bitmap
of all currently pending signals.
Added the 'sig_handlers' element to the task structure. This is an array
of all user-defined signal handlers. Currently, a value of 0 indicates
the default handler should be used whilst any other value is considered
to be the address of a userspace signal handler. The ability to ignore a
signal is not yet present but will be added sometime soon.
Added the sys_signal system call to register a signal.
Added the stub function sighandler_default() to sched.c which handles
all signals not caught by the user.
Diffstat (limited to 'include/kernel/sched.h')
| -rw-r--r-- | include/kernel/sched.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/kernel/sched.h b/include/kernel/sched.h index 42b5b15..ac508b9 100644 --- a/include/kernel/sched.h +++ b/include/kernel/sched.h @@ -1,6 +1,7 @@ #ifndef _SCHED_H #define _SCHED_H +#include <signal.h> #include <stdint.h> #include <unistd.h> @@ -39,9 +40,17 @@ struct tss_struct { uint32_t io_map; } __attribute__((packed)); +/* + * WARNING: do not modify this structure + * unless the offsets defined in traps.s + * are updated + */ + struct task_struct { pid_t pid; int state; + uint32_t signal; + void *sig_handlers[NRSIG]; struct tss_struct tss; } __attribute__((packed)); |
