Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crestaa committed Jul 16, 2022
1 parent b60443a commit e493882
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/pandos_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
#define OKCHARTRANS 5
#define TRANSMITCHAR 2


#define SEEKTOCYL 2
#define DISKREAD 3
#define DISKWRITE 4
Expand Down
23 changes: 8 additions & 15 deletions src/sys_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include "vm_support.h"


/* TODO Trovare altrernativa */
#define PRINTCHR 2

#define LOG(s) log("SS", s)
#define LOGi(s, i) logi("SS", s, i)

Expand Down Expand Up @@ -57,12 +54,11 @@ inline int write_to_printer(unsigned int virtAddr, int len, unsigned int asid){
if(*((char*)(virtAddr+i)) == '\0'){ //fine stringa
break;
}
SYSCALL(DOIO, (int)&dev_reg->command, PRINTCHR, 0);
SYSCALL(DOIO, (int)&dev_reg->command, TRANSMITCHAR, 0);
if(dev_reg->status != READY)
return -dev_reg->status;
}
return i;
//TODO bloccare processo chiamante durante la trasmissione


//sospende il processo chiamante fino alla fine della trasmissione al printer associato al processo
Expand Down Expand Up @@ -94,7 +90,6 @@ inline int write_to_terminal(unsigned int virtAddr, int len, unsigned int asid){
return -dev_reg->transm_status;
}
return i;
//TODO bloccare processo chiamante durante la trasmissione

//sospende il processo chiamante fino alla fine della trasmissione al terminale associato al processo
//PARAMETRI: indirizzo virtuale del primo carattere della stringa da trasmettere + lunghezza della stringa
Expand Down Expand Up @@ -135,6 +130,10 @@ inline int read_from_terminal(unsigned int virtAddr, unsigned int asid){ //

void support_exec_handler(void){
support_t* act_proc_sup = (support_t*)SYSCALL(GETSUPPORTPTR,0,0,0);
if(act_proc_sup == NULL){
//LOG("Error on get support");
return; //TODO gestire l'errore meglio
}
unsigned int cause = CAUSE_GET_EXCCODE(act_proc_sup->sup_exceptState[GENERALEXCEPT].cause);
if(cause == EXC_SYS){
support_syscall_handler(act_proc_sup);
Expand All @@ -152,17 +151,11 @@ void support_exec_handler(void){


void support_syscall_handler(support_t* act_proc_sup){
unsigned int arg1, arg2, arg3; /* FIXEM sicuri che arg3 non venga mai usato ????*/

if(act_proc_sup == NULL){ //TODO forse questo controllo va tolto / va messo nel support_handler() perchè viene già fatto a priori dalla passup or die quindi è ridondante
//LOG("Error on get support");
return; //TODO gestire l'errore meglio
}
unsigned int arg1, arg2;

int number = CAUSE_GET_EXCCODE(act_proc_sup->sup_exceptState[GENERALEXCEPT].cause);
arg1 = act_proc_sup->sup_exceptState[1].reg_a1;
arg2 = act_proc_sup->sup_exceptState[1].reg_a2;
arg3 = act_proc_sup->sup_exceptState[1].reg_a3;


int ret=-2147483648; //uso MININT per evitare conflitti con i valori di ritorno che possono essere numeri negativi, 0 e positivi
Expand Down Expand Up @@ -209,11 +202,11 @@ void support_trap_handler(support_t* act_proc_sup){
//TODO STA ROBA E' DA CONTROLLARE MOLTO ATTENTAMENTE
pcb_t *tmp =remove_blocked(&swp_pl_sem);

if(tmp.p_pid != act_proc.p_pid)
if(tmp->p_pid != act_proc->p_pid)
insert_blocked(&swp_pl_sem, tmp);

//se il processo tiene mutua esclusione su un semaforo mutex del livello supporto (es. swap pool sem)
//rilascia la risorsa (NSYS4 / verhogen?)
//ammazza il processo (SYS2)
terminate();
SYSCALL(TERMINATE,0,0,0);
}

0 comments on commit e493882

Please sign in to comment.