summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kernel/intmsghandler.C65
-rw-r--r--src/kernel/msghandler.C78
-rw-r--r--src/kernel/syscall.C56
3 files changed, 105 insertions, 94 deletions
diff --git a/src/kernel/intmsghandler.C b/src/kernel/intmsghandler.C
index 7b994f006..98f941f4c 100644
--- a/src/kernel/intmsghandler.C
+++ b/src/kernel/intmsghandler.C
@@ -1,26 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/kernel/intmsghandler.C $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
-
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/kernel/intmsghandler.C $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2011-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
#include <kernel/intmsghandler.H>
#include <sys/msg.h>
#include <util/singleton.H>
@@ -73,10 +73,6 @@ void InterruptMsgHdlr::create(MessageQueue * i_msgQ)
void InterruptMsgHdlr::handleInterrupt()
{
- // Save the current task in case we context-switch away when sending
- // the message.
- task_t* t = TaskManager::getCurrentTask();
-
uint64_t pir = getPIR();
uint64_t xirrAddress = (static_cast<uint64_t>(ICPBAR_VAL) << 20);
@@ -116,31 +112,16 @@ void InterruptMsgHdlr::handleInterrupt()
// Story 41868 - Mask off all interrupts very early - might
// resolve this TODO.
- // Return the task to the scheduler queue if we did a context-switch.
- if (TaskManager::getCurrentTask() != t)
- {
- t->cpu->scheduler->addTask(t);
- }
}
// TODO where does this get called from? (story 39878)
void InterruptMsgHdlr::addCpuCore(uint64_t i_pir)
{
- // Save the current task in case we context-switch away when sending
- // the message.
- task_t* t = TaskManager::getCurrentTask();
-
if(cv_instance)
{
cv_instance->sendMessage(MSG_INTR_ADD_CPU,(void *)i_pir,NULL,NULL);
}
-
- // Return the task to the scheduler queue if we did a context-switch.
- if (TaskManager::getCurrentTask() != t)
- {
- t->cpu->scheduler->addTask(t);
- }
}
MessageHandler::HandleResult InterruptMsgHdlr::handleResponse
diff --git a/src/kernel/msghandler.C b/src/kernel/msghandler.C
index 08859633a..71a9d84d1 100644
--- a/src/kernel/msghandler.C
+++ b/src/kernel/msghandler.C
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/kernel/msghandler.C $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/kernel/msghandler.C $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2011-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
#include <assert.h>
#include <errno.h>
#include <util/locked/queue.H>
@@ -33,6 +34,9 @@
void MessageHandler::sendMessage(msg_sys_types_t i_type, void* i_key,
void* i_data, task_t* i_task)
{
+ // Task to switch to due to waiter being ready to handle message.
+ task_t* ready_task = NULL;
+
// Save pending info for when we get the response.
MessageHandler_Pending* mhp = new MessageHandler_Pending;
mhp->key = i_key;
@@ -64,21 +68,41 @@ void MessageHandler::sendMessage(msg_sys_types_t i_type, void* i_key,
{
TASK_SETRTN(waiter, (uint64_t) m);
iv_msgq->responses.insert(mp);
- waiter->cpu = i_task->cpu;
- TaskManager::setCurrentTask(waiter);
+ ready_task = waiter;
}
iv_msgq->lock.unlock();
}
// Defer task while waiting for message response.
- if ((NULL != i_task) && (TaskManager::getCurrentTask() == i_task))
+ if (NULL != i_task)
{
// Set block status.
i_task->state = TASK_STATE_BLOCK_USRSPACE;
i_task->state_info = i_key;
- // Select next task off scheduler.
- i_task->cpu->scheduler->setNextRunnable();
+ if (i_task == TaskManager::getCurrentTask())
+ {
+ // Switch to ready waiter, or pick a new task off the scheduler.
+ if (ready_task)
+ {
+ TaskManager::setCurrentTask(ready_task);
+ ready_task = NULL;
+ }
+ else
+ {
+ // Select next task off scheduler.
+ i_task->cpu->scheduler->setNextRunnable();
+ }
+ }
+ }
+
+ // Switch to ready waiter.
+ if (NULL != ready_task)
+ {
+ task_t* current = TaskManager::getCurrentTask();
+ current->cpu->scheduler->addTask(current);
+ TaskManager::setCurrentTask(ready_task);
+ ready_task = NULL;
}
// Insert pending info into our queue until response is recv'd.
diff --git a/src/kernel/syscall.C b/src/kernel/syscall.C
index cfcbed860..dd3d10949 100644
--- a/src/kernel/syscall.C
+++ b/src/kernel/syscall.C
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/kernel/syscall.C $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2010 - 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/kernel/syscall.C $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2010-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
#include <assert.h>
#include <errno.h>
#include <kernel/cpu.H>
@@ -48,7 +49,8 @@ void kernel_execute_decrementer()
cpu_t* c = CpuManager::getCurrentCPU();
Scheduler* s = c->scheduler;
TimeManager::checkReleaseTasks(s);
- s->returnRunnable();
+
+ task_t* current_task = TaskManager::getCurrentTask();
CpuManager::executePeriodics(c);//TODO is there still a potential deadlock?
@@ -63,8 +65,12 @@ void kernel_execute_decrementer()
#endif
KernelMisc::shutdown();
}
- CpuManager::executePeriodics(c);
- s->setNextRunnable();
+
+ if (current_task == TaskManager::getCurrentTask())
+ {
+ s->returnRunnable();
+ s->setNextRunnable();
+ }
}
namespace Systemcalls
OpenPOWER on IntegriCloud