/** * TTY's interrupt handler. Functinality depends on status of TTY's * status port. On WIRQ status writes internal buffer from * tty_real_device_t data structure to data port. On RIRQ * status reads data from data port to the internal buffer. * Implements read from the gbd interface. * * @param device Pointer to the TTY device. */ void tty_interrupt_handle(device_t *device) { volatile tty_io_area_t *iobase = (tty_io_area_t *)device->io_address; volatile tty_real_device_t *tty_rd = (tty_real_device_t *)device->real_device; if(TTY_STATUS_WIRQ(iobase->status)) { spinlock_acquire(tty_rd->slock); iobase->command = TTY_COMMAND_WIRQD; iobase->command = TTY_COMMAND_WIRQ; while(!TTY_STATUS_WBUSY(iobase->status) && tty_rd->write_count > 0) { iobase->command = TTY_COMMAND_WIRQ; iobase->data = tty_rd->write_buf[tty_rd->write_head]; tty_rd->write_head = (tty_rd->write_head + 1) % TTY_BUF_SIZE; tty_rd->write_count--; } iobase->command = TTY_COMMAND_WIRQE; if (tty_rd->write_count == 0) sleepq_wake_all((void *)tty_rd->write_buf); spinlock_release(tty_rd->slock); } if(TTY_STATUS_RIRQ(iobase->status)) { spinlock_acquire(tty_rd->slock); iobase->command = TTY_COMMAND_RIRQ; if (TTY_STATUS_ERROR(iobase->status)) KERNEL_PANIC("Could not issue RIRQ to TTY."); while (TTY_STATUS_RAVAIL(iobase->status)) { char data = iobase->data; int index; if (tty_rd->read_count > TTY_BUF_SIZE) continue; index = (tty_rd->read_head + tty_rd->read_count) % TTY_BUF_SIZE; tty_rd->read_buf[index] = data; tty_rd->read_count++; } spinlock_release(tty_rd->slock); sleepq_wake_all((void *)tty_rd->read_buf); } }
void condition_broadcast(cond_t *cond, lock_t *condition_lock){ interrupt_status_t intr_status; intr_status = _interrupt_disable(); spinlock_acquire(&(cond->spinlock)); lock_acquire(condition_lock); sleepq_wake_all(cond); lock_release(condition_lock); spinlock_release(&(cond->spinlock)); }
/* Stop the current process and the kernel thread in which it runs Argument: return value */ void process_exit(int retval){ process_id_t pid; thread_table_t * thr; kprintf("starten af exit. reval: %d \n",retval); if (retval < 0){ return; } // gets the process id pid = process_get_current_process(); thr = thread_get_current_thread_entry(); //spinlock spinlock_acquire(&process_table_slock); //Disbale interrupt _interrupt_set_state(_interrupt_disable()); // set the process state to ZOMBIE process_table[pid].state = STATE_ZOMBIE; // Set the process retval to given retval process_table[pid].retval = retval; //cleanup vm_destroy_pagetable(thr->pagetable); thr->pagetable = NULL; /* Wake process */ sleepq_wake_all(&process_table[pid]); /* Unlock the process table */ spinlock_release(&process_table_slock); //enable interrupts _interrupt_set_state(_interrupt_disable()); kprintf("slutningen af exit :O \n"); thread_finish(); }
void process_finish(int retval) { interrupt_status_t intr_status; process_id_t cur = process_get_current_process(); thread_table_t *thread = thread_get_current_thread_entry(); intr_status = _interrupt_disable(); spinlock_acquire(&process_table_slock); process_table[cur].state = PROCESS_ZOMBIE; process_table[cur].retval = retval; /* Remember to destroy the pagetable! */ vm_destroy_pagetable(thread->pagetable); thread->pagetable = NULL; sleepq_wake_all(&process_table[cur]); spinlock_release(&process_table_slock); _interrupt_set_state(intr_status); thread_finish(); }
/* * Signal all threads waiting for the given condition */ void condition_broadcast(cond_t *cond, lock_t *condition_lock) { condition_lock = condition_lock; sleepq_wake_all(cond); // Wake up all waiting threads }
void condition_broadcast (cond_t *cond, lock_t *lock ) { lock = lock; sleepq_wake_all(&cond); }
int condition_reset(cond_t *cond) { sleepq_wake_all(cond); return 0; }
void condition_broadcast(cond_t *cond, lock_t *condition_lock) { sleepq_wake_all(cond); // flyt alle processer fra q til e }