hw5: mostly done
This commit is contained in:
parent
71591aa85c
commit
aa03d859f6
2 changed files with 7 additions and 3 deletions
|
@ -427,6 +427,7 @@ thread_exit (void)
|
||||||
{
|
{
|
||||||
ASSERT (!intr_context ());
|
ASSERT (!intr_context ());
|
||||||
|
|
||||||
|
|
||||||
#ifdef USERPROG
|
#ifdef USERPROG
|
||||||
process_exit ();
|
process_exit ();
|
||||||
#endif
|
#endif
|
||||||
|
@ -436,7 +437,7 @@ thread_exit (void)
|
||||||
when it calls thread_schedule_tail(). */
|
when it calls thread_schedule_tail(). */
|
||||||
intr_disable ();
|
intr_disable ();
|
||||||
struct thread* t = thread_current();
|
struct thread* t = thread_current();
|
||||||
//printf("Exit status: %d\n",t->exit_status);
|
printf("%s: exit(%d)\n", t->name, t->exit_status);
|
||||||
list_remove (&t->allelem);
|
list_remove (&t->allelem);
|
||||||
sema_up(&t->waiting_sem);
|
sema_up(&t->waiting_sem);
|
||||||
sema_down(&t->parent->parent_sem);
|
sema_down(&t->parent->parent_sem);
|
||||||
|
@ -589,6 +590,7 @@ init_thread (struct thread *t, const char *name, int priority)
|
||||||
sema_init(&t->waiting_sem, 0);
|
sema_init(&t->waiting_sem, 0);
|
||||||
sema_init(&t->parent_sem, 0);
|
sema_init(&t->parent_sem, 0);
|
||||||
t->waited_on_before = 0;
|
t->waited_on_before = 0;
|
||||||
|
t->exit_status = -1;
|
||||||
list_init(&t->children);
|
list_init(&t->children);
|
||||||
|
|
||||||
if (thread_mlfqs) {
|
if (thread_mlfqs) {
|
||||||
|
|
|
@ -218,7 +218,10 @@ int sys_read(int fd, void *buffer, unsigned size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_write(int fd, const void *buffer, unsigned size) {
|
int sys_write(int fd, const void *buffer, unsigned size) {
|
||||||
if (check_ptr(buffer)||check_ptr(buffer+size)) return -1;
|
unsigned i;
|
||||||
|
for (i = 0; i <= size; i++) {
|
||||||
|
if (check_ptr(buffer + size)) return -1;
|
||||||
|
}
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if(fd == 1) { // write to stdout
|
if(fd == 1) { // write to stdout
|
||||||
|
@ -266,7 +269,6 @@ int
|
||||||
sys_exit (int status)
|
sys_exit (int status)
|
||||||
{
|
{
|
||||||
struct thread* t = thread_current();
|
struct thread* t = thread_current();
|
||||||
printf("%s: exit(%d)\n", t->name, status);
|
|
||||||
t->exit_status = status;
|
t->exit_status = status;
|
||||||
thread_exit();
|
thread_exit();
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Reference in a new issue