From 1d9def9edae0011eeee8f83dc32fb3797ca2f46b Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 7 Oct 2011 15:36:12 -0700 Subject: More work in the Task manager. Also fixing a few bugs linked with the printer and TLS. Removed flto from compilation flags: this actually creates bad code (!) --- src/Task.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Task.cc') diff --git a/src/Task.cc b/src/Task.cc index d41f088..9bdad0c 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -9,10 +9,16 @@ Balau::Task::Task() { stack = malloc(size); coro_create(&ctx, coroutine, this, stack, size); taskMan = TaskMan::getTaskMan(); + taskMan->registerTask(this); tls = tlsManager->createTLS(); status = STARTING; } +Balau::Task::~Task() { + free(stack); + free(tls); +} + void Balau::Task::coroutine(void * arg) { Task * task = reinterpret_cast(arg); Assert(task); @@ -38,7 +44,8 @@ void Balau::Task::switchTo() { tlsManager->setTLS(tls); coro_transfer(&taskMan->returnContext, &ctx); tlsManager->setTLS(oldTLS); - status = IDLE; + if (status == RUNNING) + status = IDLE; } void Balau::Task::suspend() { -- cgit v1.2.3