Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Commit

Permalink
add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
CCXXXI committed Jan 10, 2021
1 parent b5252b8 commit ec53c97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/userprog/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tid_t process_execute(const char *file_name)

palloc_free_page(fn_copy0);

if (thread_current()->tid != 1)
if (thread_current()->tid != 1 && tid != TID_ERROR)
{
struct process *self = thread_current()->process;
struct process *child = get_process(tid);
Expand Down Expand Up @@ -604,6 +604,8 @@ struct process *process_create(struct thread *t)
/* Get struct process in ALL_LIST by pid. */
struct process *get_process(pid_t pid)
{
ASSERT(pid != TID_ERROR);

struct list *l = &all_list;

for (struct list_elem *e = list_begin(l); e != list_end(l); e = list_next(e))
Expand All @@ -620,6 +622,8 @@ struct process *get_process(pid_t pid)
Returns NULL if not found. */
struct process *get_child(pid_t pid)
{
ASSERT(pid != TID_ERROR);

struct list *l = &thread_current()->process->children;

for (struct list_elem *e = list_begin(l); e != list_end(l); e = list_next(e))
Expand Down

0 comments on commit ec53c97

Please sign in to comment.