1 / 15

Generalidades

MINIX3 SYSTEM TASK Cátedra: Diseño e Implementación de Sistemas Operativos UTN-FRSF Tomado de: Operating Systems Design and Implementation, Third Edition. Generalidades.

azra
Télécharger la présentation

Generalidades

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MINIX3SYSTEM TASKCátedra: Diseño e Implementación de Sistemas Operativos UTN-FRSFTomado de: Operating Systems Design and Implementation, Third Edition

  2. Generalidades • Como consecuencias de que la mayor cantidad de componentes están fuera del kernel como procesos independientes, ellos están inhibidos de realizar ciertas operaciones privilegidadas. • Manipulación de Tablas del Kernel • Operaciones de Entrada/Salida • Copias de areas de memoria entre procesos • La solución es que el kernel ofrezca esos servicios a Drivers y Servers (no a procesos de usuario ordinarios). • Estos servicios se brindan a traves de un proceso que se llama SYSTEM TASK (SYSTASK) que es un representante del kernel. • SYSTASK se compila en el mismo binario que el kernel y accede a todas sus variables y funciones.

  3. Generalidades • Un ejemplo de uso de la SYSTASK por parte de un Device Driver en modo usuario es el uso de la Kernel call sys_irqctl para instalar un handler de interrupción. • En realidad lo que hace la SYSTASK es instalar un generic_handler que se encarga de notificar a la tarea correspondiente del Device Driver. • El programa main() de la SYSTASK funciona en forma similar al resto de las tareas. Es un loop que espera una petición a través de un mensaje, despacha el procedimiento correspondiente y retorna una respuesta. • El programa main() se encuentra en system.c del directorio del kernel. El resto de los procedimientos en el directorio system.

  4. Mensajes a SYSTASK

  5. Mensajes a SYSTASK

  6. Mensajes a SYSTASK

  7. Mensajes a SYSTASK • Los Kernel Calls sys_irqctl, sys_devio, sys_sdevio, y sys_vdevio son provistos por MINIX3 para soportar los Device Drivers en espacio de usuario. • sys_newmap es invocado por el PM cuando ha cambiado la memoria asignada al proceso, por lo tanto el Kernel debe actualizar sus tablas. • Sys_segctl y sys_memset brindan una forma segura de que el proceso pueda acceder a areas de memoria fuera de su espacio de usuario. El area de memoria desde 0xa0000 to 0xfffff se reserva para dispositivos de E/S. Sys_segctl es usaso por los Device Drivers para obtener el Selector del Segmento que le permitirá acceder a ese rango de memoria.

  8. Mensajes a SYSTASK • sys_memset se usa para escribir datos en un area de memoria que no le pertenece al proceso, como por ejemplo para poner Ceros en ella. • Sys_umap convierte direcciones virtuales en direcciones físicas. • Sys_vircopy y sys_physcopy copian regiones de memoria utilizando direccionamiento virtual o físico. • sys_virvcopy y sys_physvcopy son las versiones vectorizadas de las previsas. • sys_getinfo maneja un amplio rango de pedidos de información al Kernel.

  9. Implementacion de SYSTASK 09753 /*===========================================================================* 09754 * sys_task * 09755 *===========================================================================*/ 09756 PUBLIC void sys_task() 09757 { 09758 /* Main entry point of sys_task. Get the message and dispatch on type. */ 09759 static message m; 09760 register int result; 09761 register struct proc *caller_ptr; 09762 unsigned int call_nr; 09763 int s; 09765 /* Initialize the system task. */ 09766 initialize(); 09768 while (TRUE) { 09769 /* Get work. Block and wait until a request message arrives. */ 09770 receive(ANY, &m); 09771 call_nr = (unsigned) m.m_type - KERNEL_CALL; 09772 caller_ptr = proc_addr(m.m_source); 09773 09774 /* See if the caller made a valid request and try to handle it. */ 09775 if (! (priv(caller_ptr)->s_call_mask & (1<<call_nr))) { 09776 kprintf("SYSTEM: request %d from %d denied.\n", call_nr,m.m_source); 09777 result = ECALLDENIED; /* illegal message type */ 09778 } else if (call_nr >= NR_SYS_CALLS) { /* check call number */ 09779 kprintf("SYSTEM: illegal request %d from %d.\n", call_nr,m.m_source); 09780 result = EBADREQUEST; /* illegal message type */ 09781 } 09782 else { 09783 result = (*call_vec[call_nr])(&m); /* handle the kernel call */ 09784 }

  10. Implementacion de SYSTASK 09786 /* Send a reply, unless inhibited by a handler function. Use the kernel 09787 * function lock_send() to prevent a system call trap. The destination 09788 * is known to be blocked waiting for a message. 09789 */ 09790 if (result != EDONTREPLY) { 09791 m.m_type = result; /* report status of call */ 09792 if (OK != (s=lock_send(m.m_source, &m))) { 09793 kprintf("SYSTEM, reply to %d failed: %d\n", m.m_source, s); 09794 } 09795 } 09796 } 09797 }

  11. Implementacion de SYSTASK 09747 #define map(call_nr, handler) \ 09748 {extern int dummy[NR_SYS_CALLS>(unsigned)(call_nr-KERNEL_CALL) ? 1:-1];} \ 09749 call_vec[(call_nr-KERNEL_CALL)] = (handler) 09799 /*===========================================================================* 09800 * initialize * 09801 *===========================================================================*/ 09802 PRIVATE void initialize(void) 09803 { 09804 register struct priv *sp; 09805 int i; 09806 09807 /* Initialize IRQ handler hooks. Mark all hooks available. */ 09808 for (i=0; i<NR_IRQ_HOOKS; i++) { 09809 irq_hooks[i].proc_nr = NONE; 09810 } 09811 09812 /* Initialize all alarm timers for all processes. */ 09813 for (sp=BEG_PRIV_ADDR; sp < END_PRIV_ADDR; sp++) { 09814 tmr_inittimer(&(sp->s_alarm_timer)); 09815 } 09816 09817 /* Initialize the call vector to a safe default handler. Some kernel calls 09818 * may be disabled or nonexistant. Then explicitly map known calls to their 09819 * handler functions. This is done with a macro that gives a compile error 09820 * if an illegal call number is used. The ordering is not important here. 09821 */ 09822 for (i=0; i<NR_SYS_CALLS; i++) { 09823 call_vec[i] = do_unused; 09824 }

  12. Implementacion de SYSTASK 09826 /* Process management. */ 09827 map(SYS_FORK, do_fork); /* a process forked a new process */ 09828 map(SYS_EXEC, do_exec); /* update process after execute */ 09829 map(SYS_EXIT, do_exit); /* clean up after process exit */ 09830 map(SYS_NICE, do_nice); /* set scheduling priority */ 09831 map(SYS_PRIVCTL, do_privctl); /* system privileges control */ 09832 map(SYS_TRACE, do_trace); /* request a trace operation */ 09833 09834 /* Signal handling. */ 09835 map(SYS_KILL, do_kill); /* cause a process to be signaled */ 09836 map(SYS_GETKSIG, do_getksig); /* PM checks for pending signals */ 09837 map(SYS_ENDKSIG, do_endksig); /* PM finished processing signal */ 09838 map(SYS_SIGSEND, do_sigsend); /* start POSIX-style signal */ 09839 map(SYS_SIGRETURN, do_sigreturn); /* return from POSIX-style signal */ 09840 09841 /* Device I/O. */ 09842 map(SYS_IRQCTL, do_irqctl); /* interrupt control operations */ 09843 map(SYS_DEVIO, do_devio); /* inb, inw, inl, outb, outw, outl */ 09844 map(SYS_SDEVIO, do_sdevio); /* phys_insb, _insw, _outsb, _outsw */ 09845 map(SYS_VDEVIO, do_vdevio); /* vector with devio requests */ 09846 map(SYS_INT86, do_int86); /* real-mode BIOS calls */ 09847 09848 /* Memory management. */ 09849 map(SYS_NEWMAP, do_newmap); /* set up a process memory map */ 09850 map(SYS_SEGCTL, do_segctl); /* add segment and get selector */ 09851 map(SYS_MEMSET, do_memset); /* write char to memory area */

  13. Implementacion de SYSTASK 09853 /* Copying. */ 09854 map(SYS_UMAP, do_umap); /* map virtual to physical address */ 09855 map(SYS_VIRCOPY, do_vircopy); /* use pure virtual addressing */ 09856 map(SYS_PHYSCOPY, do_physcopy); /* use physical addressing */ 09857 map(SYS_VIRVCOPY, do_virvcopy); /* vector with copy requests */ 09858 map(SYS_PHYSVCOPY, do_physvcopy); /* vector with copy requests */ 09859 09860 /* Clock functionality. */ 09861 map(SYS_TIMES, do_times); /* get uptime and process times */ 09862 map(SYS_SETALARM, do_setalarm); /* schedule a synchronous alarm */ 09863 09864 /* System control. */ 09865 map(SYS_ABORT, do_abort); /* abort MINIX */ 09866 map(SYS_GETINFO, do_getinfo); /* request system information */ 09867 }

  14. Impacto en Performance • USER->FS read • FS->DD Si no esta en cache rw_block() • DD->SYSTASK sys_devio • SYSTASK->DD ACK • SYSTASK->DD INTERRUPT • DD->SYSTASK sys_copy from kernel to FS cache • SYSTASK->DD ACK • DD->FS ACK • FS->SYSTASK sys_copy from FS cache to user buffer • SYSTASK->FS ACK • FS->USER ACK

  15. Impacto en Performance • USER->FS read • FS->SYSTASK sys_copy from FS cache to user buffer • SYSTASK->FS ACK • FS->USER ACK

More Related