| Age | Commit message (Collapse) | Author |
|
Now, reschedule() requires a task to be in the TSTATE_RUNNING state for
it to run.
Renamed the TSS structure within the task structure from 'state' to
'tss' to avoid confusion with the task's run state.
Removed the task_state structure declaration from sched.c as it is no
longer needed due to context switches now being performed entirely in
hardware.
Removed the cstate pointer from sched.c. Interrupt handlers no longer
set a pointer to saved state information on the stack since this was
only needed for software task switching. NOTE: This may be re-introduced
should it become necessary to access state information on the stack.
Added a basic implementation of the wake_up() scheduling primative. This
function is currently not used and may be completely re-written in
future.
|
|
Since the kernel now has it's own stack unique to each address space, we
can now rely on hardware task switching to *also* save the task states.
To accomplish this, most of the code in switch_to() has been elimated.
This includes; the clearing of the busy flag in the old TSS on each
switch, setting the TR register to null prior to each switch and calling
save_state() (which has also been removed entirely), to copy the state
information.
Modified the for loop in reschedule() to account for the fact that the
switch_to() function may now return (which it *always* does when
returning to the task). For the same reason, switch_to() must also be
careful to preserve registers such as EBX and actually make a return
following the far jump.
Added basic definitions for task states in sched.h. These are; running,
interruptible, uninterruptible, zombie and stopped. These states will
(possibly) be used in the future to implement blocking system calls.
|
|
during process creation. This new kernel stack is placed at 0xFFFFFFFF,
as the last page in the 4GB address space. The base of the user's stack
has been moved down to 0xFFFFDFFF, exactly two pages below. The extra
page below the kernel's stack page will be left unmapped so as to
trigger a page fault if the kernel's stack overflows.
The initial values of the user's TSS have also been updated to reflect
the new bases of the stacks, and to ensure that the kernel's unique
stack is loaded when an interrupt occurs.
|
|
longer calls reschedule() directly. It now calls sched_tick() so that
the scheduler can make it's own decisions relating to handling the timer
interrupt.
The reschedule() function now *actually* implements a basic round-robin
scheduling algorithm that iterates through the list of tasks. This is
still a temporary algorithm but at least it now includes *all* runnable
processes instead of switching back and forth between process 1 and 2.
|
|
each structure has a TSS inside, as well as several descriptor entries
in the GDT pointing to each task's TSS. Task switching is performed in
hardware by means of far jumping to the new task's TSS descriptor in the
GDT. Task states are saved manually by copying the saved state from the
interrupt handler's stack, back into the task's TSS.
Added the function save_state() to sched.c which can be called from
assembly to copy the state information of the suspended task from the
current stack, to it's respective task structure. NOTE: this assumes
that the pointer cstate has been set ahead of time to point to the state
information on the stack, and that the pointer ctask has not yet been
modified.
Added the function reschedule() which is currently called from the
timer's tick handler. Currently, this function merely alternates between
the two tasks created in sched_init(), but in future, will be expanded
to decided independently which task will run next.
The function userspace_init() was renamed to the more appropriate
sched_init().
Moved most of the code from the original userspace_init() to the new
function create_proc() which sets up a virtual address space and state
information, copies the specified binary into the new address space,
then returns a pointer to the newly created tasks entry in the task
table.
Defined the type pid_t in unistd.h as a 16-bit unsigned integer.
Added two new debugging system calls for checking which task is
currently active. The getpid() system calls returns the caller's PID
whilst the getpdir() call returns the physical location of the caller's
page directory (the value of CR3). The getpdir() call can be used as a
fallback to determine which task is *actually* running if the
information in ctask or the getpid() call is faulty.
Added two new subroutines; set_tss() and clear_tss() (whose prototypes
are defined in asm/system.h) for managing the task-state descriptor
entries in the GDT. set_tss() initializes a TSS descriptor and sets it's
base pointer to the supplied TSS pointer whilst clear_tss() simply marks
a TSS descriptor as 'not present' without clearing it.
|
|
vsprintf() function to render formatted strings and then the puts system
call to output them.
Moved the vsprintf() function from the kernel to the library.
Furthermore, the prototype for the function has been moved from the
kernel's headers, to the new header file stdio.h.
Renamed the kernel's internal printf() function to printk() in order to
avoid confusion with the library provided function.
Renamed the sys_print system call to the more appropriate name,
sys_puts.
Added a new system call sys_time, which returns the system's uptime in
seconds. This is mainly for testing the userspace binary and will not be
permanent.
Added the file time.c to the library which contains the caller for
sys_time and a helper routine sleep() which delays execution for the
specified number of seconds. The new header file time.h contains
prototypes for both these functions as well as the definition for the
type time_t.
Fixed a bug in which the value of EAX was not properly passed to the
system call handler, resulting in the wrong system call being executed.
This was caused by the code in the SAVE macro not properly preserving
the value.
Fixed a bug in which the value of EAX was not preserved during a return
from system call, but rather restored with the original EAX value prior
to the call. As a result, system call return codes were not properly
passed. This has been corrected by introducing a new macro RESTORE_SYS
which carries out the same restore operations, but maintains EAX prior
to the return.
|
|
is produced. This may change later.
Added the new directory 'lib' to the source tree which build lib.a, an
archive containing common library routines for both the kernel and
userspace code to use.
Added the file string.c to the lib directory (as well as the appropriate
headers in /include) which provides some basic functions from the
standard C string library.
Added a physical memory manager which is now located in memory.c. This
memory manager tracks free pages from 1MB-8MB with a simple table and
allocates memory in blocks of 4KB pages. Multiple pages can be allocated
in which they are returned as a linked list.
Added a 'page window' in memory.c which allows the temporary mapping of
a single page at a time into the current address space.
Moved all paging routines that were previously located in page.s over to
memory.c where they have been re-implemented as a mixture of C and
inline assembly.
Moved the primative userspace routines from usrspace.s over to the new
sched.c. The only remaining routine, usrcall is now located in asm.s as
'switch_to' which takes two arguments, pointers to the task structure
and task state structure of the new task which is being switched to.
Pages for userspace are now allocated dynamically. The user binary is
loaded in at 1GB upwards. The user stack is located at the end of the
4GB address space with the lower 1GB being reserved for the kernel.
Updated the link.ld file for the userspace binary to include the new
starting address 0x40000000 (1GB).
Renamed the symbols for the user binary blob to make them shorter.
|