summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel/taskmgr.C40
-rw-r--r--src/usr/testcore/kernel/taskwaittest.H2
-rw-r--r--src/usr/testcore/kernel/vmmbasetest.H47
-rw-r--r--src/usr/testcore/kernel/vmmpagetest.H31
-rw-r--r--src/usr/vfs/vfsrp.C2
5 files changed, 69 insertions, 53 deletions
diff --git a/src/kernel/taskmgr.C b/src/kernel/taskmgr.C
index 0ed493801..ad2aa3af5 100644
--- a/src/kernel/taskmgr.C
+++ b/src/kernel/taskmgr.C
@@ -33,6 +33,7 @@
#include <arch/ppc.H>
#include <string.h>
#include <limits.h>
+#include <assert.h>
extern "C" void userspace_task_entry();
@@ -169,13 +170,13 @@ void TaskManager::_endTask(task_t* t, void* retval, int status)
if (getCurrentTask() == t)
t->cpu->scheduler->setNextRunnable();
+ iv_spinlock.lock();
+
// Update status in tracker.
t->tracker->status = status;
t->tracker->retval = retval;
t->tracker->task = NULL; // NULL signifies task is complete for now.
- iv_spinlock.lock();
-
if (t->detached) // If detached, just clean up the tracker.
{
removeTracker(t->tracker);
@@ -207,6 +208,19 @@ void TaskManager::_endTask(task_t* t, void* retval, int status)
parent->task->cpu->scheduler->addTask(parent->task);
}
}
+ else if (!t->tracker->parent) // Parented by kernel.
+ {
+ if (status == TASK_STATUS_CRASHED)
+ {
+ printk("Critical: Parentless task %d crashed.\n",
+ t->tid);
+ kassert(status != TASK_STATUS_CRASHED);
+ }
+ else
+ {
+ removeTracker(t->tracker);
+ }
+ }
}
iv_spinlock.unlock();
@@ -326,7 +340,27 @@ void TaskManager::removeTracker(task_tracking_t* t)
while(task_tracking_t* child = t->children.remove())
{
child->parent = parent;
- trackingList->insert(child);
+ if ((!parent) && (!child->task)) // Deal with finished children
+ // becoming parented by the kernel.
+ {
+ if (child->status == TASK_STATUS_CRASHED)
+ {
+ trackingList->insert(child); // Insert into kernel list so it
+ // is there for debug.
+
+ printk("Critical: Parentless task %d crashed.\n",
+ child->key);
+ kassert(child->status != TASK_STATUS_CRASHED);
+ }
+ else
+ {
+ removeTracker(child);
+ }
+ }
+ else
+ {
+ trackingList->insert(child);
+ }
}
// Delete tracker object.
diff --git a/src/usr/testcore/kernel/taskwaittest.H b/src/usr/testcore/kernel/taskwaittest.H
index 00ec0990f..8c59aedc7 100644
--- a/src/usr/testcore/kernel/taskwaittest.H
+++ b/src/usr/testcore/kernel/taskwaittest.H
@@ -171,7 +171,7 @@ class TaskWaitTest : public CxxTest::TestSuite
static void TaskThatCrashes(void* unused)
{
- printk("Test case: Expect to see uncaught exception!");
+ printk("Test case: Expect to see uncaught exception! ");
*(int64_t*)(0) = 0xDEADC0DE;
}
};
diff --git a/src/usr/testcore/kernel/vmmbasetest.H b/src/usr/testcore/kernel/vmmbasetest.H
index cd2f20ff1..52802fee7 100644
--- a/src/usr/testcore/kernel/vmmbasetest.H
+++ b/src/usr/testcore/kernel/vmmbasetest.H
@@ -37,27 +37,25 @@
class VmmBaseTest : public CxxTest::TestSuite
{
public:
- static volatile int rc;
static msg_q_t iv_mq;
void testNullAccess()
{
- rc = 0; sync();
+ int status;
+
printk("Test case: Expect to see uncaught exception! ");
- task_create(readFromNULL, NULL);
- while (rc == 0) task_yield();
- task_yield();
- if (rc == -1)
+ tid_t child = task_create(readFromNULL, NULL);
+
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("Write to NULL not caught.");
}
- rc = 0; sync();
printk("Test case: Expect to see uncaught exception! ");
- task_create(writeToNULL, NULL);
- while (rc == 0) task_yield();
- task_yield();
- if (rc == -1)
+ child = task_create(writeToNULL, NULL);
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("Write to NULL not caught.");
}
@@ -65,12 +63,12 @@ class VmmBaseTest : public CxxTest::TestSuite
void testWriteToKernelCode()
{
- rc = 0; sync();
+ int status;
+
printk("Test case: Expect to see uncaught exception! ");
- task_create(writeToKernelCode, NULL);
- while (rc == 0) task_yield();
- task_yield();
- if (rc == -1)
+ tid_t child = task_create(writeToKernelCode, NULL);
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("Write to kernel code not caught.");
}
@@ -97,7 +95,7 @@ class VmmBaseTest : public CxxTest::TestSuite
uint64_t l_testSize = VMM_SIZE_RMVPAGE_TEST;
uint64_t vaddr = l_testAddr+l_testSize;
uint64_t vsize = PageManager::availPages()*PAGESIZE;
- rc = mm_alloc_block(iv_mq,reinterpret_cast<void*>(vaddr),vsize);
+ int rc = mm_alloc_block(iv_mq,reinterpret_cast<void*>(vaddr),vsize);
if (rc != 0)
{
TS_FAIL("Unable to allocate block.\n");
@@ -128,25 +126,19 @@ class VmmBaseTest : public CxxTest::TestSuite
static void readFromNULL(void* unused)
{
- rc = 1; sync();
- printk("%lx", (*(uint64_t*)NULL)); sync();
- rc = -1; sync();
+ printk("%lx", (*(uint64_t*)NULL));
task_end();
}
static void writeToNULL(void* unused)
{
- rc = 1; sync();
- (*(uint64_t*)NULL) = 0x12345678; sync();
- rc = -1; sync();
+ (*(uint64_t*)NULL) = 0x12345678;
task_end();
}
static void writeToKernelCode(void* unused)
{
- rc = 1; sync();
- (*(*(uint64_t**)&printk)) = 0x12345678; sync();
- rc = -1; sync();
+ (*(*(uint64_t**)&printk)) = 0x12345678;
task_end();
}
@@ -163,13 +155,12 @@ class VmmBaseTest : public CxxTest::TestSuite
/*printkd("Effective Addr: 0x%lX, %s\n",ea,
message->type==MSG_MM_RP_READ?"READ":"WRITE");*/
message->data[1] = 0;
- rc = msg_respond(iv_mq, message);
+ msg_respond(iv_mq, message);
}
}
}
};
-volatile int VmmBaseTest::rc = 0;
msg_q_t VmmBaseTest::iv_mq = msg_q_create();
#endif
diff --git a/src/usr/testcore/kernel/vmmpagetest.H b/src/usr/testcore/kernel/vmmpagetest.H
index 3559fd3cb..0edbd78f3 100644
--- a/src/usr/testcore/kernel/vmmpagetest.H
+++ b/src/usr/testcore/kernel/vmmpagetest.H
@@ -39,7 +39,6 @@ class vmmpagetest: public CxxTest::TestSuite
public:
static volatile int rc;
- static volatile int iv_rc;
//Testing page removal variables
static msg_q_t iv_mq;
static uint64_t iv_va;
@@ -148,12 +147,11 @@ class vmmpagetest: public CxxTest::TestSuite
}
// try to write to a read_only page
- iv_rc = 0; sync();
+ int status;
printk("\nTest case1: Expect to see uncaught exception! ");
- task_create(writeAddrWithNoPerm, NULL);
- while (iv_rc == 0) task_yield();
- task_yield();
- if (iv_rc == -1)
+ tid_t child = task_create(writeAddrWithNoPerm, NULL);
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("ERROR! Write to READ_ONLY address not caught.");
}
@@ -165,12 +163,10 @@ class vmmpagetest: public CxxTest::TestSuite
}
// try to write to an executable page
- iv_rc = 0; sync();
printk("\nTest case2: Expect to see uncaught exception! ");
- task_create(writeAddrWithNoPerm2, NULL);
- while (iv_rc == 0) task_yield();
- task_yield();
- if (iv_rc == -1)
+ child = task_create(writeAddrWithNoPerm2, NULL);
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("ERROR! Write to EXECUTABLE address not caught.");
}
@@ -182,12 +178,10 @@ class vmmpagetest: public CxxTest::TestSuite
}
// try to write to a no access page
- iv_rc = 0; sync();
printk("\nTest case3: Expect to see uncaught exception! ");
- task_create(writeAddrWithNoPerm, NULL);
- while (iv_rc == 0) task_yield();
- task_yield();
- if (iv_rc == -1)
+ child = task_create(writeAddrWithNoPerm, NULL);
+ if ((child != task_wait_tid(child, &status, NULL)) ||
+ (status != TASK_STATUS_CRASHED))
{
TS_FAIL("ERROR! write to a NO_ACCESS addr not caught.\n");
}
@@ -238,24 +232,19 @@ class vmmpagetest: public CxxTest::TestSuite
static void writeAddrWithNoPerm(void* unused)
{
- iv_rc = 1; sync();
(*(volatile uint64_t *)(iv_va+4*PAGESIZE)) = 0x11111111; sync();
- iv_rc = -1; sync();
task_end();
}
static void writeAddrWithNoPerm2(void* unused)
{
- iv_rc = 1; sync();
(*(volatile uint64_t *)(iv_va+4*PAGESIZE+2*PAGESIZE)) = 0x22222222; sync();
- iv_rc = -1; sync();
task_end();
}
};
volatile int vmmpagetest::rc = 0;
-volatile int vmmpagetest::iv_rc = 0;
msg_q_t vmmpagetest::iv_mq = msg_q_create();
uint64_t vmmpagetest::iv_va = VMM_VADDR_RMVPAGE_TEST;
uint64_t vmmpagetest::iv_size = VMM_SIZE_RMVPAGE_TEST;
diff --git a/src/usr/vfs/vfsrp.C b/src/usr/vfs/vfsrp.C
index 9c178e92a..6f8f41620 100644
--- a/src/usr/vfs/vfsrp.C
+++ b/src/usr/vfs/vfsrp.C
@@ -90,6 +90,7 @@ void VfsRp::msg_handler(void * unused)
void VfsRp::load_unload(void * i_msg)
{
+ task_detach();
Singleton<VfsRp>::instance()._load_unload((msg_t*)i_msg);
task_end();
}
@@ -98,6 +99,7 @@ void VfsRp::load_unload(void * i_msg)
void VfsRp::exec(void * i_msg)
{
+ task_detach();
Singleton<VfsRp>::instance()._exec((msg_t*)i_msg);
task_end();
}
OpenPOWER on IntegriCloud