diff options
| author | klaar36 <klas.arvidsson@liu.se> | 2016-05-04 02:55:52 +0200 |
|---|---|---|
| committer | klaar36 <klas.arvidsson@liu.se> | 2016-05-04 02:55:52 +0200 |
| commit | 6d80739be4f882005c98a4b8000c1c5cde8d0a4e (patch) | |
| tree | 2fbd306663ad74350c97d21d8774284389b368ee /src/threads | |
| parent | 9336320b82d48403d982502e358242072d2a9a1a (diff) | |
| download | pintos-rs-6d80739be4f882005c98a4b8000c1c5cde8d0a4e.tar.gz | |
recursive poweroff fix
Diffstat (limited to 'src/threads')
| -rw-r--r-- | src/threads/init.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/threads/init.c b/src/threads/init.c index 43f491f..e4df408 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -53,6 +53,10 @@ bool force_off_when_done = false; /* -tcf: Simulate failure in thread_create klaar@ida... */ int thread_create_limit = 0; /* infinite */ +static bool prevent_reqursive_off = false; + +static void hard_power_off (void) NO_RETURN; + static void ram_init (void); static void paging_init (void); @@ -369,24 +373,20 @@ usage (void) #endif ); - /* klaar@ida disabled due to threads and locks not initialized + /* klaar@ida changed due to threads and locks not initialized * yet... and power_off() now use locks. */ -// power_off (); + hard_power_off (); } - /* Powers down the machine we're running on, as long as we're running on Bochs or QEMU. */ -void -power_off (void) +static void +hard_power_off (void) { const char s[] = "Shutdown"; const char *p; - printf ("# Preparing to power off...\n"); - DEBUG_thread_poweroff_check( force_off_when_done ); - #ifdef FILESYS filesys_done (); #endif @@ -412,6 +412,22 @@ power_off (void) for (;;); } +/* Powers down the machine we're running on, + as long as we're running on Bochs or QEMU. */ +void +power_off (void) +{ + if ( prevent_reqursive_off ) + hard_power_off (); + + prevent_reqursive_off = true; + + printf ("# Preparing to power off...\n"); + DEBUG_thread_poweroff_check( force_off_when_done ); + + hard_power_off (); +} + /* Print statistics about Pintos execution. */ static void print_stats (void) |
