projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clarify use of timer_sleep or acceptable alternatives for implementing
[pintos-anon]
/
src
/
threads
/
init.c
diff --git
a/src/threads/init.c
b/src/threads/init.c
index a624ef57edf02a2b3aa7b392e5a4fc37abded034..2931704120c67bf39441ce56aa469a128b556e39 100644
(file)
--- a/
src/threads/init.c
+++ b/
src/threads/init.c
@@
-9,6
+9,7
@@
#include <stdlib.h>
#include <string.h>
#include "devices/kbd.h"
#include <stdlib.h>
#include <string.h>
#include "devices/kbd.h"
+#include "devices/input.h"
#include "devices/serial.h"
#include "devices/timer.h"
#include "devices/vga.h"
#include "devices/serial.h"
#include "devices/timer.h"
#include "devices/vga.h"
@@
-40,11
+41,6
@@
size_t ram_pages;
/* Page directory with kernel mappings only. */
uint32_t *base_page_dir;
/* Page directory with kernel mappings only. */
uint32_t *base_page_dir;
-/* -mlfqs:
- If false (default), use round-robin scheduler.
- If true, use multi-level feedback queue scheduler. */
-bool enable_mlfqs;
-
#ifdef FILESYS
/* -f: Format the file system? */
static bool format_filesys;
#ifdef FILESYS
/* -f: Format the file system? */
static bool format_filesys;
@@
-108,6
+104,7
@@
main (void)
intr_init ();
timer_init ();
kbd_init ();
intr_init ();
timer_init ();
kbd_init ();
+ input_init ();
#ifdef USERPROG
exception_init ();
syscall_init ();
#ifdef USERPROG
exception_init ();
syscall_init ();
@@
-166,15
+163,17
@@
paging_init (void)
{
uint32_t *pd, *pt;
size_t page;
{
uint32_t *pd, *pt;
size_t page;
+ extern char _start, _end_kernel_text;
pd = base_page_dir = palloc_get_page (PAL_ASSERT | PAL_ZERO);
pt = NULL;
for (page = 0; page < ram_pages; page++)
{
uintptr_t paddr = page * PGSIZE;
pd = base_page_dir = palloc_get_page (PAL_ASSERT | PAL_ZERO);
pt = NULL;
for (page = 0; page < ram_pages; page++)
{
uintptr_t paddr = page * PGSIZE;
-
void
*vaddr = ptov (paddr);
+
char
*vaddr = ptov (paddr);
size_t pde_idx = pd_no (vaddr);
size_t pte_idx = pt_no (vaddr);
size_t pde_idx = pd_no (vaddr);
size_t pte_idx = pt_no (vaddr);
+ bool in_kernel_text = &_start <= vaddr && vaddr < &_end_kernel_text;
if (pd[pde_idx] == 0)
{
if (pd[pde_idx] == 0)
{
@@
-182,7
+181,7
@@
paging_init (void)
pd[pde_idx] = pde_create (pt);
}
pd[pde_idx] = pde_create (pt);
}
- pt[pte_idx] = pte_create_kernel (vaddr,
true
);
+ pt[pte_idx] = pte_create_kernel (vaddr,
!in_kernel_text
);
}
/* Store the physical address of the page directory into CR3
}
/* Store the physical address of the page directory into CR3
@@
-219,7
+218,10
@@
read_command_line (void)
/* Print kernel command line. */
printf ("Kernel command line:");
for (i = 0; i < argc; i++)
/* Print kernel command line. */
printf ("Kernel command line:");
for (i = 0; i < argc; i++)
- printf (" %s", argv[i]);
+ if (strchr (argv[i], ' ') == NULL)
+ printf (" %s", argv[i]);
+ else
+ printf (" '%s'", argv[i]);
printf ("\n");
return argv;
printf ("\n");
return argv;
@@
-247,7
+249,7
@@
parse_options (char **argv)
else if (!strcmp (name, "-rs"))
random_init (atoi (value));
else if (!strcmp (name, "-mlfqs"))
else if (!strcmp (name, "-rs"))
random_init (atoi (value));
else if (!strcmp (name, "-mlfqs"))
-
enable
_mlfqs = true;
+
thread
_mlfqs = true;
#ifdef USERPROG
else if (!strcmp (name, "-ul"))
user_page_limit = atoi (value);
#ifdef USERPROG
else if (!strcmp (name, "-ul"))
user_page_limit = atoi (value);
@@
-362,7
+364,7
@@
usage (void)
/* Powers down the machine we're running on,
/* Powers down the machine we're running on,
- as long as we're running on Bochs or
qemu
. */
+ as long as we're running on Bochs or
QEMU
. */
void
power_off (void)
{
void
power_off (void)
{
@@
-380,6
+382,8
@@
power_off (void)
for (p = s; *p != '\0'; p++)
outb (0x8900, *p);
for (p = s; *p != '\0'; p++)
outb (0x8900, *p);
+ asm ("cli; hlt");
+ printf ("still running...\n");
for (;;);
}
for (;;);
}