schedule: move schedule.c --> schedule.cc
authorBrian Norris <banorris@uci.edu>
Wed, 14 Mar 2012 22:56:56 +0000 (15:56 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 14 Mar 2012 22:57:48 +0000 (15:57 -0700)
Makefile
schedule.c [deleted file]
schedule.cc [new file with mode: 0644]

index 6c52f671d92023ca361bf395fbe5677986c8e3a4..84a7b0a10a1e9d9a39c0656978b47d9c322d6922 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 CC=g++
 BIN=libthreads
-SOURCE=libthreads.c schedule.c libatomic.c userprog.c model.cc
+SOURCE=libthreads.c schedule.cc libatomic.c userprog.c model.cc
 HEADERS=libthreads.h schedule.h common.h libatomic.h model.h
 FLAGS=-Wall
 
diff --git a/schedule.c b/schedule.c
deleted file mode 100644 (file)
index 4f5f3de..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <stdlib.h>
-
-#include "libthreads.h"
-#include "schedule.h"
-#include "common.h"
-#include "model.h"
-
-struct thread_list_node {
-       struct thread *t;
-       struct thread_list_node *next;
-       int live;
-};
-
-#define NUM_LIST_NODES 32
-
-struct thread_list_node *head, *tail;
-struct thread_list_node nodes[NUM_LIST_NODES];
-struct thread *current;
-
-static void enqueue_thread(struct thread *t)
-{
-       int i;
-       struct thread_list_node *node;
-
-       for (node = nodes, i = 0; node->live && i < NUM_LIST_NODES; i++, node++);
-       if (i >= NUM_LIST_NODES) {
-               printf("ran out of nodes\n");
-               exit(1);
-       }
-       node->t = t;
-       node->next = NULL;
-       node->live = 1;
-
-       if (tail)
-               tail->next = node;
-       else
-               head = node;
-       tail = node;
-}
-
-static struct thread *dequeue_thread(void)
-{
-       struct thread *pop;
-
-       if (!head)
-               return NULL;
-
-       pop = head->t;
-       head->live = 0;
-       if (head == tail)
-               tail = NULL;
-       head = head->next;
-
-       /* Set new current thread */
-       current = pop;
-
-       return pop;
-}
-
-void DefaultScheduler::add_thread(struct thread *t)
-{
-       DEBUG("thread %d\n", t->id);
-       enqueue_thread(t);
-}
-
-struct thread *DefaultScheduler::next_thread(void)
-{
-       return dequeue_thread();
-}
-
-struct thread *DefaultScheduler::get_current_thread(void)
-{
-       return current;
-}
diff --git a/schedule.cc b/schedule.cc
new file mode 100644 (file)
index 0000000..4f5f3de
--- /dev/null
@@ -0,0 +1,74 @@
+#include <stdlib.h>
+
+#include "libthreads.h"
+#include "schedule.h"
+#include "common.h"
+#include "model.h"
+
+struct thread_list_node {
+       struct thread *t;
+       struct thread_list_node *next;
+       int live;
+};
+
+#define NUM_LIST_NODES 32
+
+struct thread_list_node *head, *tail;
+struct thread_list_node nodes[NUM_LIST_NODES];
+struct thread *current;
+
+static void enqueue_thread(struct thread *t)
+{
+       int i;
+       struct thread_list_node *node;
+
+       for (node = nodes, i = 0; node->live && i < NUM_LIST_NODES; i++, node++);
+       if (i >= NUM_LIST_NODES) {
+               printf("ran out of nodes\n");
+               exit(1);
+       }
+       node->t = t;
+       node->next = NULL;
+       node->live = 1;
+
+       if (tail)
+               tail->next = node;
+       else
+               head = node;
+       tail = node;
+}
+
+static struct thread *dequeue_thread(void)
+{
+       struct thread *pop;
+
+       if (!head)
+               return NULL;
+
+       pop = head->t;
+       head->live = 0;
+       if (head == tail)
+               tail = NULL;
+       head = head->next;
+
+       /* Set new current thread */
+       current = pop;
+
+       return pop;
+}
+
+void DefaultScheduler::add_thread(struct thread *t)
+{
+       DEBUG("thread %d\n", t->id);
+       enqueue_thread(t);
+}
+
+struct thread *DefaultScheduler::next_thread(void)
+{
+       return dequeue_thread();
+}
+
+struct thread *DefaultScheduler::get_current_thread(void)
+{
+       return current;
+}