diff options
| author | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2012-03-27 11:51:08 +0200 |
| commit | 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch) | |
| tree | 868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /pintos-progos/tests/threads/mlfqs-block.c | |
| parent | eae0bd57f0a26314a94785061888d193d186944a (diff) | |
| download | progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2 progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip | |
reorganize file structure to match the upstream requirements
Diffstat (limited to 'pintos-progos/tests/threads/mlfqs-block.c')
| -rw-r--r-- | pintos-progos/tests/threads/mlfqs-block.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/pintos-progos/tests/threads/mlfqs-block.c b/pintos-progos/tests/threads/mlfqs-block.c deleted file mode 100644 index 6d4992d..0000000 --- a/pintos-progos/tests/threads/mlfqs-block.c +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | /* Checks that recent_cpu and priorities are updated for blocked | ||
| 2 | threads. | ||
| 3 | |||
| 4 | The main thread sleeps for 25 seconds, spins for 5 seconds, | ||
| 5 | then releases a lock. The "block" thread spins for 20 seconds | ||
| 6 | then attempts to acquire the lock, which will block for 10 | ||
| 7 | seconds (until the main thread releases it). If recent_cpu | ||
| 8 | decays properly while the "block" thread sleeps, then the | ||
| 9 | block thread should be immediately scheduled when the main | ||
| 10 | thread releases the lock. */ | ||
| 11 | |||
| 12 | #include <stdio.h> | ||
| 13 | #include "tests/threads/tests.h" | ||
| 14 | #include "threads/init.h" | ||
| 15 | #include "threads/malloc.h" | ||
| 16 | #include "threads/synch.h" | ||
| 17 | #include "threads/thread.h" | ||
| 18 | #include "devices/timer.h" | ||
| 19 | |||
| 20 | static void block_thread (void *lock_); | ||
| 21 | |||
| 22 | void | ||
| 23 | test_mlfqs_block (void) | ||
| 24 | { | ||
| 25 | int64_t start_time; | ||
| 26 | struct lock lock; | ||
| 27 | |||
| 28 | ASSERT (thread_mlfqs); | ||
| 29 | |||
| 30 | msg ("Main thread acquiring lock."); | ||
| 31 | lock_init (&lock); | ||
| 32 | lock_acquire (&lock); | ||
| 33 | |||
| 34 | msg ("Main thread creating block thread, sleeping 25 seconds..."); | ||
| 35 | thread_create ("block", PRI_DEFAULT, block_thread, &lock); | ||
| 36 | timer_sleep (25 * TIMER_FREQ); | ||
| 37 | |||
| 38 | msg ("Main thread spinning for 5 seconds..."); | ||
| 39 | start_time = timer_ticks (); | ||
| 40 | while (timer_elapsed (start_time) < 5 * TIMER_FREQ) | ||
| 41 | continue; | ||
| 42 | |||
| 43 | msg ("Main thread releasing lock."); | ||
| 44 | lock_release (&lock); | ||
| 45 | |||
| 46 | msg ("Block thread should have already acquired lock."); | ||
| 47 | } | ||
| 48 | |||
| 49 | static void | ||
| 50 | block_thread (void *lock_) | ||
| 51 | { | ||
| 52 | struct lock *lock = lock_; | ||
| 53 | int64_t start_time; | ||
| 54 | |||
| 55 | msg ("Block thread spinning for 20 seconds..."); | ||
| 56 | start_time = timer_ticks (); | ||
| 57 | while (timer_elapsed (start_time) < 20 * TIMER_FREQ) | ||
| 58 | continue; | ||
| 59 | |||
| 60 | msg ("Block thread acquiring lock..."); | ||
| 61 | lock_acquire (lock); | ||
| 62 | |||
| 63 | msg ("...got it."); | ||
| 64 | } | ||
