Skip to content
Snippets Groups Projects
Commit 9f59fe2b authored by abinade2's avatar abinade2
Browse files

grep now works

parent c9ffa12a
No related branches found
No related tags found
No related merge requests found
......@@ -86,8 +86,10 @@ int32_t rtc_read(int32_t fd, void* buf, int32_t nbytes)
//interrupt_flag = 1;
sti();
/* Wait until interrupt handler clears flag */
while (rtc_flag[running_terminal]);
cli();
return 0;
......@@ -176,8 +178,15 @@ int32_t rtc_write(int32_t fd, const void* buf, int32_t nbytes)
*/
int32_t rtc_open(const uint8_t* filename)
{
int32_t freq = 2;
/* Set RTC to active for the running terminal */
rtc_active[running_terminal] = 1;
rtc_counter[running_terminal] = INIT_FREQ/freq;
rtc_init_counter[running_terminal] = rtc_counter[running_terminal];
return 0;
......
......@@ -206,9 +206,9 @@ int32_t execute(const uint8_t* command){
terminal[running_terminal].pcb = pcb_ptr;
//printf("[EXE] using pcb = %x\n", terminal[visible_terminal].pcb);
//printf("[EXE] using pcb = %x\n", terminal[running_terminal].pcb);
//printf("[EXE] set pcb ebp to %x , esp to %x\n", terminal[visible_terminal].pcb->current_ebp, terminal[visible_terminal].pcb->current_esp);
//printf("[EXE] set pcb ebp to %x , esp to %x\n", terminal[running_terminal].pcb->current_ebp, terminal[running_terminal].pcb->current_esp);
//printf("[EXE] should be ebp %x , esp %x\n", temp_ebp, temp_esp);
//--------------------- 6: scheduling initilization -----------------------
......@@ -271,7 +271,7 @@ int32_t read (int32_t fd_n, void* buf, int32_t nbytes){
if (nbytes < 0) return -1; // invalid nbytes
//terminal[visible_terminal].pcb = current_pcb();
//terminal[running_terminal].pcb = current_pcb();
/* Enable for keyboard interrupts */
//sti();
......@@ -338,7 +338,7 @@ int32_t open (const uint8_t* filename){
int type;
dentry_t dentry;
terminal[ visible_terminal].pcb = current_pcb();
//terminal[ running_terminal].pcb = current_pcb();
/* Valid file name check */
if( strlen( (char*)filename ) == 0 ) return -1;
......@@ -354,7 +354,7 @@ int32_t open (const uint8_t* filename){
for(i = USER_FILE_START; i < MAX_FILE_NUM; i++){
/* Check if FD table entry is unused */
if( terminal[ visible_terminal].pcb->fd[i].flags == 0)
if( terminal[ running_terminal].pcb->fd[i].flags == 0)
{
fd = i;
break;
......@@ -365,25 +365,25 @@ int32_t open (const uint8_t* filename){
}
terminal[ visible_terminal].pcb->fd[fd].inode_index = (type == 2)? dentry.inode_index : 0;
terminal[ visible_terminal].pcb->fd[fd].file_pos = 0;
terminal[ visible_terminal].pcb->fd[fd].flags = 1;
terminal[ running_terminal].pcb->fd[fd].inode_index = (type == 2)? dentry.inode_index : 0;
terminal[ running_terminal].pcb->fd[fd].file_pos = 0;
terminal[ running_terminal].pcb->fd[fd].flags = 1;
switch (type) {
case 0:
terminal[ visible_terminal].pcb->fd[fd].fileop_ptr = rtc_jumptable;
terminal[ running_terminal].pcb->fd[fd].fileop_ptr = rtc_jumptable;
break;
case 1:
terminal[ visible_terminal].pcb->fd[fd].fileop_ptr = dir_jumptable;
terminal[ running_terminal].pcb->fd[fd].fileop_ptr = dir_jumptable;
break;
case 2:
terminal[ visible_terminal].pcb->fd[fd].fileop_ptr = file_jumptable;
terminal[ running_terminal].pcb->fd[fd].fileop_ptr = file_jumptable;
break;
}
sti();
//sti();
terminal[ visible_terminal].pcb->fd[fd].fileop_ptr.open(filename);
terminal[running_terminal].pcb->fd[fd].fileop_ptr.open(filename);
return fd;
}
......@@ -402,11 +402,11 @@ int32_t close (int32_t fd){
if (fd_check(fd) < 0 || fd < USER_FILE_START) return -1; // invalid fd
terminal[ visible_terminal].pcb = current_pcb();
//terminal[ running_terminal].pcb = current_pcb();
sti();
//sti();
terminal[ visible_terminal].pcb->fd[fd].fileop_ptr.close(fd);
terminal[ running_terminal].pcb->fd[fd].fileop_ptr.close(fd);
fd_clear(fd);
......@@ -433,10 +433,10 @@ int32_t getargs (uint8_t* buf, int32_t nbytes){
uint8_t* argument;
terminal[ visible_terminal].pcb = current_pcb();
argument = (uint8_t*) ( terminal[ visible_terminal].pcb->argv);
//terminal[ running_terminal].pcb = current_pcb();
argument = (uint8_t*) ( terminal[ running_terminal].pcb->argv);
if( terminal[ visible_terminal].pcb->arg_num == 0 || nbytes <= 0 )
if( terminal[ running_terminal].pcb->arg_num == 0 || nbytes <= 0 )
{
//printf("[getargs] return -1\n");
return -1; //If there are no arguments
......@@ -448,8 +448,8 @@ int32_t getargs (uint8_t* buf, int32_t nbytes){
memcpy(buf, argument, nbytes);
// uint32_t i;
// //printf("[getargs] argument number = %d\n", terminal[ visible_terminal].pcb->arg_num);
// for(i = 0; i < terminal[ visible_terminal].pcb->arg_num; i++)
// //printf("[getargs] argument number = %d\n", terminal[ running_terminal].pcb->arg_num);
// for(i = 0; i < terminal[ running_terminal].pcb->arg_num; i++)
// //printf("[getargs] buf[%d] = %s\n", i, buf+i*MAX_ARGUMENT_SIZE);
//printf("[getargs] return 0\n");
return 0;
......
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