Skip to content
Snippets Groups Projects
Commit 7cc010b4 authored by arthur's avatar arthur
Browse files

more comments and modification

parent f6a6b09a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
#include "terminal.h" #include "terminal.h"
#include "filesys.h" #include "filesys.h"
/* Mask to get 8KB page */
#define PCB_M 0xFFFFE000
extern int32_t fail(); // Error handling helper function extern int32_t fail(); // Error handling helper function
extern void control_initilization(void); extern void control_initilization(void);
extern void exit(void); extern void exit(void);
......
#include "scheduler.h" #include "scheduler.h"
/* The scheduler function
*
* DISCRIPTION: This function switch running process every 15 ms
*
*/
void scheduler(void){ void scheduler(void){
//printf("schedule counter = %d\n", ++counter);
// Bookkeeping // Bookkeeping
pcb_t * curr_pcb = terminal[running_terminal].pcb; pcb_t * curr_pcb = terminal[running_terminal].pcb;
...@@ -10,7 +14,7 @@ void scheduler(void){ ...@@ -10,7 +14,7 @@ void scheduler(void){
{ {
// initialize pcb and set esp and ebp // initialize pcb and set esp and ebp
// scheduler_flag used in execute to override pcb_init ebp and esp // scheduler_flag used in execute to override pcb_init ebp and esp
pcb_t pcb; pcb_t pcb;
pcb.scheduler_flag = 1; pcb.scheduler_flag = 1;
...@@ -24,8 +28,6 @@ void scheduler(void){ ...@@ -24,8 +28,6 @@ void scheduler(void){
terminal[running_terminal].pcb = &pcb; terminal[running_terminal].pcb = &pcb;
//printf("[SCHEDULE] ebp = %x , esp = %x\n", pcb.current_ebp, pcb.current_esp);
switch_terminal(running_terminal); switch_terminal(running_terminal);
printf("terminal = %d\n", running_terminal); printf("terminal = %d\n", running_terminal);
...@@ -57,19 +59,12 @@ void scheduler(void){ ...@@ -57,19 +59,12 @@ void scheduler(void){
pcb_t* next_pcb = terminal[running_terminal].pcb; pcb_t* next_pcb = terminal[running_terminal].pcb;
//printf("[SCHEDULE] curr_pcb = %x , next_pcb = %x\n", curr_pcb, next_pcb);
// update current pid, tss and remap paging // update current pid, tss and remap paging
remap_proc(next_pcb->pid); remap_proc(next_pcb->pid);
tss.ss0 = KERNEL_DS; tss.ss0 = KERNEL_DS;
tss.esp0 = _8_MB - _8_KB * (next_pcb->pid); tss.esp0 = _8_MB - _8_KB * (next_pcb->pid);
//printf("[SCHEDULE] esp = %x ebp = %x pid = %d pcb = %x\n", next_pcb->current_esp, next_pcb->current_ebp, next_pcb->pid, next_pcb);
// cli();
//while(1);
send_eoi(0); send_eoi(0);
asm volatile( asm volatile(
......
#include "lib.h" #include "lib.h"
#include "types.h" #include "types.h"
#include "x86_desc.h" #include "x86_desc.h"
#include "terminal.h"
#include "syscall.h"
#include "paging.h"
int32_t remap_proc(int32_t pid);
extern void scheduler(void); extern void scheduler(void);
/* function needed from other place */
int32_t execute (const uint8_t* command);
int32_t switch_terminal(int32_t term_id);
int32_t remap_proc(int32_t pid);
void remap2(int32_t term_id);
void remap_vidmem();
...@@ -103,7 +103,7 @@ int32_t execute(const uint8_t* command) ...@@ -103,7 +103,7 @@ int32_t execute(const uint8_t* command)
int32_t ret, arg_num; //number that indicated special command int32_t ret, arg_num; //number that indicated special command
int32_t pid = set_pid(); int32_t pid = set_pid();
//if( pid == -1) return -1; // reach max process //if( pid == -1) return -1; // reach max process
ret = parse_cmd(command, parsed_cmd, argv); ret = parse_cmd(command, parsed_cmd, argv);
......
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