Skip to content
Snippets Groups Projects
Commit 01051829 authored by Tom Feng's avatar Tom Feng
Browse files

quit works, modified scheduler a bit

parent 0ecdaeb6
Branches backup727
No related tags found
2 merge requests!16Withtime,!15Samplek4
......@@ -30,4 +30,5 @@ Buffer** GetAllSendQ();
int AwaitEvent(int EventID);
void QuitProgram();
#endif
......@@ -269,7 +269,8 @@ typedef enum syscall {
SYS_GETC,
SYS_PUTC,
SYS_SHARED,
SYS_GETSHARED
SYS_GETSHARED,
SYS_QUIT
} Syscall;
......
......@@ -297,6 +297,7 @@ void Display() {
Putc(COM1,'a');
//QuitProgram();
*(int *)(UART1_BASE) = 97;
QuitProgram();
// Exit();
break;
case OnTrain:
......
......@@ -6,7 +6,7 @@
int pushToScheduler (KernelStruct* Colonel, TD* Task) {
InsertMinHeap(Colonel->Scheduler,Task->TaskID,Task->NextPriority);
Task->NextPriority = Task->TaskPriority;
//Task->NextPriority = Task->TaskPriority;
//int returncode= PushToTDPQ(&(Colonel->ArrayPQ)[Task->TaskPriority],Task);
//bwprintf(COM1,"PUSH: pushed %d(prio: %d) to scheuler result%d\n\r",Task->TaskID,Task->TaskPriority,returncode);
return 0;
......@@ -14,7 +14,9 @@ int pushToScheduler (KernelStruct* Colonel, TD* Task) {
void LoadNextTask(KernelStruct* Colonel){
int TaskID,Priority;
if(GetMinMinHeap(Colonel->Scheduler,&TaskID,&Priority)){
if(Colonel->Scheduler->Num == 0){
Colonel->Active = NULL;
}else if(GetMinMinHeap(Colonel->Scheduler,&TaskID,&Priority)){
RemoveMinMinHeap(Colonel->Scheduler);
if(!isTaskAvailable(TaskID)){
Colonel->Active = (Colonel->Tasks)+ (GetMemoryIndexINT(TaskID));
......
......@@ -214,6 +214,12 @@ void Handle(KernelStruct* Colonel, int n) {
case SYS_GETSHARED:
Colonel->Active->RetVal = (int )(Colonel->Shared);
break;
case SYS_QUIT:
Colonel->Active = NULL;
Colonel->Scheduler->Num = 0;
Colonel->Scheduler->Last = 0;
//bwprintf(COM2,"HD: quit\n\r");
break;
}
//bwprintf(COM2,"Handle: Before returning\n\r");
}
......@@ -233,6 +239,7 @@ void fakeExit(TD* Task){
}
int Activate(KernelStruct *Colonel,TD* Task) {
Task->NextPriority = Task->TaskPriority;
//if(Colonel->Active == NULL) Colonel->Active = Task;
//fakeExit(Task);
// bwprintf(COM2, "Activate: about to kerxit\n\r");
......
......@@ -144,3 +144,7 @@ int GetShared(){
int Ret = RetVal;
return Ret;
}
void QuitProgram(){
asm volatile("swi 16\n\t");
}
......@@ -62,6 +62,7 @@ int main()
//bwprintf(COM1,"main: before get new from scheduler \n\r");
//Task = getNextTaskScheduler(&Colonel);
LoadNextTask(&Colonel);
Task = Colonel.Active;
}
else{
Task = Colonel.Active;
......@@ -69,7 +70,7 @@ int main()
}
if(Task == NULL){
//bwprintf(COM1,"main: no active task, break");
//bwprintf(COM2,"main: no active task, break");
break;
}
//bwprintf(COM1,"main: Task%d, Priority: %d\n\r", Task->TaskID,Task->TaskPriority);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment