projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5e64014
)
Don't palloc_free() the initial thread, because it's not allocated
author
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 13 Sep 2004 02:13:52 +0000
(
02:13
+0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 13 Sep 2004 02:13:52 +0000
(
02:13
+0000)
from a palloc pool.
src/threads/thread.c
patch
|
blob
|
history
diff --git
a/src/threads/thread.c
b/src/threads/thread.c
index ea3562fd39367387c5b272bc2ebabd98e64c0b9b..1b56f98508e16922de88d299cf02ec2f6f0a22f1 100644
(file)
--- a/
src/threads/thread.c
+++ b/
src/threads/thread.c
@@
-25,6
+25,10
@@
static struct list ready_list;
static struct thread *idle_thread; /* Thread. */
static void idle (void *aux UNUSED); /* Thread function. */
static struct thread *idle_thread; /* Thread. */
static void idle (void *aux UNUSED); /* Thread function. */
+/* Initial thread.
+ This is the thread running main(). */
+static struct thread *initial_thread;
+
/* Stack frame for kernel_thread(). */
struct kernel_thread_frame
{
/* Stack frame for kernel_thread(). */
struct kernel_thread_frame
{
@@
-57,14
+61,12
@@
void schedule_tail (struct thread *prev);
void
thread_init (void)
{
void
thread_init (void)
{
- struct thread *t;
-
ASSERT (intr_get_level () == INTR_OFF);
/* Set up a thread structure for the running thread. */
ASSERT (intr_get_level () == INTR_OFF);
/* Set up a thread structure for the running thread. */
-
t
= running_thread ();
- init_thread (
t
, "main");
-
t
->status = THREAD_RUNNING;
+
initial_thread
= running_thread ();
+ init_thread (
initial_thread
, "main");
+
initial_thread
->status = THREAD_RUNNING;
/* Initialize run queue. */
list_init (&ready_list);
/* Initialize run queue. */
list_init (&ready_list);
@@
-379,7
+381,8
@@
destroy_thread (struct thread *t)
#ifdef USERPROG
addrspace_destroy (t);
#endif
#ifdef USERPROG
addrspace_destroy (t);
#endif
- palloc_free (t);
+ if (t != initial_thread)
+ palloc_free (t);
}
/* Completes a thread switch by activating the new thread's page
}
/* Completes a thread switch by activating the new thread's page