Merge branch 'user-programs-temporary-fix' into 'user-programs'
Temporary fixes for process waiting and stack setup to allow simple user programs to run See merge request lab2425_autumn/pintos_22!24
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "threads/palloc.h"
|
#include "threads/palloc.h"
|
||||||
#include "threads/thread.h"
|
#include "threads/thread.h"
|
||||||
#include "threads/vaddr.h"
|
#include "threads/vaddr.h"
|
||||||
|
#include "devices/timer.h"
|
||||||
|
|
||||||
static thread_func start_process NO_RETURN;
|
static thread_func start_process NO_RETURN;
|
||||||
static bool load (const char *cmdline, void (**eip) (void), void **esp);
|
static bool load (const char *cmdline, void (**eip) (void), void **esp);
|
||||||
@@ -88,7 +89,12 @@ start_process (void *file_name_)
|
|||||||
int
|
int
|
||||||
process_wait (tid_t child_tid UNUSED)
|
process_wait (tid_t child_tid UNUSED)
|
||||||
{
|
{
|
||||||
return -1;
|
/* As a temporary wait, waiting will just put the thread to sleep for one
|
||||||
|
second (TIMER_FREQ = 100 ticks ~ 1 second). */
|
||||||
|
/* TODO: Implement process_wait () correctly. Remove the next line. */
|
||||||
|
timer_sleep (TIMER_FREQ);
|
||||||
|
|
||||||
|
return 0; /* TODO: Change this too */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the current process's resources. */
|
/* Free the current process's resources. */
|
||||||
@@ -451,7 +457,7 @@ setup_stack (void **esp)
|
|||||||
{
|
{
|
||||||
success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true);
|
success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true);
|
||||||
if (success)
|
if (success)
|
||||||
*esp = PHYS_BASE;
|
*esp = PHYS_BASE - 12;
|
||||||
else
|
else
|
||||||
palloc_free_page (kpage);
|
palloc_free_page (kpage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user