Permalink
Browse files

meh

  • Loading branch information...
grantborthwick committed Oct 6, 2012
1 parent 1bbad99 commit 11bb05d8c3aed76880ba01f6ade745934c9a11a9
@@ -2,7 +2,7 @@
# Test names.
tests/threads_TESTS = $(addprefix tests/threads/,alarm-single \
-alarm-many alarm-multiple alarm-simultaneous alarm-priority alarm-zero \
+alarm-many alarm-multiple alarm-mega alarm-onethousand alarm-simultaneous alarm-priority alarm-zero \
alarm-negative priority-change priority-donate-one \
priority-donate-multiple priority-donate-multiple2 \
priority-donate-nest priority-donate-sema priority-donate-lower \
@@ -1,6 +1,7 @@
Functionality and robustness of alarm clock:
4 alarm-single
4 alarm-multiple
+4 alarm-mega
4 alarm-many
4 alarm-simultaneous
4 alarm-priority
@@ -1,72 +1,15 @@
-/* Checks that when the alarm clock wakes up threads, the
- higher-priority threads run first. */
+/* Tests timer_sleep(-100). Only requirement is that it not crash. */
#include <stdio.h>
#include "tests/threads/tests.h"
-#include "threads/init.h"
#include "threads/malloc.h"
#include "threads/synch.h"
#include "threads/thread.h"
#include "devices/timer.h"
-static thread_func alarm_priority_thread;
-static int64_t wake_time;
-static struct semaphore wait_sema;
-
void
test_alarm_negative (void)
{
- int i;
- int j = 0;
-
- /* This test does not work with the MLFQS. */
- ASSERT (!thread_mlfqs);
-
- wake_time = timer_ticks () + 5 * TIMER_FREQ;
- sema_init (&wait_sema, 0);
- for (i = 27; i<37; ++i){
- j += 2;
- char name[16];
- snprintf (name, sizeof name, "priority %d", i-20);
- thread_create(name,i-20, alarm_priority_thread, NULL);
- snprintf (name, sizeof name, "priority %d", i);
- thread_create(name,i, alarm_priority_thread, NULL);
- }
-
-
- /*for (i = 0; i < 10; i++)
- {
- int priority = PRI_DEFAULT - (i + 5) % 10 - 1;
- char name[16];
- snprintf (name, sizeof name, "priority %d", priority);
- thread_create (name, priority, alarm_priority_thread, NULL);
- }
- printf("starter! (%d)%s\n",(thread_current ()->priority),(thread_current ()->name));
- thread_set_priority (0);
- printf("I am the lowest thread. Now I start some more!(%d)%s\n",(thread_current ()->priority),(thread_current ()->name));
- for (i = 27; i < 38; i++)
- {
- int priority = i; //definitely weird order and sema down before others.
- char name[16];
- snprintf (name, sizeof name, "priority %d", priority);
- thread_create (name, priority, alarm_priority_thread, NULL);
- }
- timer_sleep(1000);
- for (i = 0; i < 20; i++)
- sema_up (&wait_sema);*/
- printf("(%d) all accounted for.\n", (thread_current ()->priority));
- for (i = 0; i<j; ++i){
- sema_down(&wait_sema);
- }
-}
-
-static void
-alarm_priority_thread (void *aux UNUSED)
-{
-
- //sema_down (&wait_sema);
- printf ("(%d)Thread %s here!.\n", (thread_current ()->priority) , thread_name ());
- sema_up(&wait_sema);
-
- //sema_up (&wait_sema);
+ timer_sleep (-100);
+ pass ();
}
@@ -29,6 +29,16 @@ test_alarm_many (void)
{
test_sleep (5, 14);
}
+void
+test_alarm_mega (void)
+{
+ test_sleep (5, 70);
+}
+void
+test_alarm_onethousand (void)
+{
+ test_sleep (5, 100);
+}
/* Information about the test. */
struct sleep_test
@@ -104,7 +104,7 @@ test_sleep (int thread_cnt, int iterations)
t->id = i;
t->duration = (i + 1) * 10;
t->iterations = 0;
- printf("Starting Threads");
+
snprintf (name, sizeof name, "thread %d", i);
thread_create (name, PRI_DEFAULT, sleeper, t);
}
@@ -39,6 +39,9 @@ static const struct test tests[] =
{"mlfqs-nice-2", test_mlfqs_nice_2},
{"mlfqs-nice-10", test_mlfqs_nice_10},
{"mlfqs-block", test_mlfqs_block},
+ //Tests added by Grant
+ {"alarm-mega", test_alarm_mega},
+ {"alarm-onethousand", test_alarm_onethousand},
};
static const char *test_name;
@@ -33,6 +33,9 @@ extern test_func test_mlfqs_fair_20;
extern test_func test_mlfqs_nice_2;
extern test_func test_mlfqs_nice_10;
extern test_func test_mlfqs_block;
+//Tests added by Grant
+extern test_func test_alarm_mega;
+extern test_func test_alarm_onethousand;
void msg (const char *, ...);
void fail (const char *, ...);

0 comments on commit 11bb05d

Please sign in to comment.