1 / 26

LegOS 0.2.4 Kernel

LegOS 0.2.4 Kernel. Highlights from the. Daniel Jhin Yoo March 15, 2001. The RCX Hardware. Hitachi H8/3292. 16-bit Timer. 16k ROM. 32k RAM. 8-bit Timer. A/D Converter. I/O Ports. The Hitachi H8 ROM. Start-up driver for Firmware kmain( ) Low-level subsystem routines

votaw
Télécharger la présentation

LegOS 0.2.4 Kernel

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. LegOS 0.2.4 Kernel Highlights from the Daniel Jhin Yoo March 15, 2001

  2. The RCX Hardware Hitachi H8/3292 16-bit Timer 16k ROM 32k RAM 8-bit Timer A/D Converter I/O Ports

  3. The Hitachi H8 ROM • Start-up driver for Firmware • kmain( ) • Low-level subsystem routines • A/D, Motor control, …) • ROM interrupt handlers call addresses in RAM

  4. The LegOS 0.2.4 Kernel • Kernel Initialization and Timing • kmain.c and systime.c • Task Structure and Management • tm.c • Interprocess Communication • lnp.c, lnp-logical.c and semaphore.c

  5. LegOS Startup kmain ( ) tm_init TM MM Program LNP . . . execi idle (min) packet_consumer (max) key_handler (max)

  6. Timer Interrupts 1 interrupt / ms 16-bit Timer ROM RAM ocia_vector systime_handler ( )

  7. systime_handler ( ) Polling • Increment 16-bit system timer • Motor handler • Sound handler • LNP checked for timeout • . . . • Check whether we need a task switch

  8. The Life of a LegOS Process Zombie Waiting termination wait_event ( ) free stack (scheduler) wake-up function (scheduler) Running scheduler Dead Sleeping execi( ), timeslice

  9. Scheduler Invocation systime_handler ( ) yield ( ) systime.c tm.c tm_switcher ( ) • sv reg, SP of old • ld reg, SP of new tm.c tm_scheduler ( ) • find new task • return SP of new tm.c

  10. Prioritized Round Robin w/ Task Queue pstruct_t pstruct_t pchain_t packet_consumer key_handler priority 20 tm.h tm.h pstruct_t pchain_t idle priority 1

  11. Scheduling Problems • Priority inversion • Slow response to wake-up function • Wake-up conditions checked only when Scheduler is selecting next task • Checking dependent on priorities of task set

  12. The “Vehicle Test” Stop car when you detect the line Light Sensor Car only stops 32% of the time!

  13. Solution: Prioritized Interrupts Allow user to specify an interrupt handler to a sensor event Example: “Stop the car when light sensor falls below value X”) Detect Sensor State Change Interrupt Priority > Task priority? Run Interrupt Handler Postpone Interrupt

  14. Interrupt Queue When do we handle postponed interrupts? tm_scheduler ( ) • find new task • handle inter. with priority > new task • return SP of new

  15. Results Kernel Line Width TS Miss Old 1mm 6ms 68% New 1mm 6ms 8% • Detection of interrupt no longer coupled to TS or priorities of task set. • Handlingof interrupt still dependent (e.g. car stops after line)

  16. Interprocess Communication • IR via LegOS Network Protocol • lnp.c and lnp-logical.c • Semaphores • semaphore.c

  17. LegOS Network Protocol • Two kinds of packets/services: • Integrity (“broadcast”) • Address (“UDP”)

  18. Integrity Packet F0 LEN DATA CHK F0: integrity packet (1 byte) LEN: length of DATA section (1 byte) DATA: payload data (0-255 bytes) CHK: checksum (1 byte)

  19. Addressing Packet F1 LEN DEST SRC DATA CHK F1: address packet (1 byte) LEN: DEST + DATA + SRC (1 byte) DEST: destination address (1 byte) SRC: source address (1 byte) DATA: payload data (0-253 bytes) CHK: checksum (1 byte)

  20. LNP Interrupt Driven 32 interrupts / ms 8-bit Timer ROM RAM rxi_vector txi_vector rx_handler ( ) tx_handler ( )

  21. Life of a Packet (Sender) lnp_addressing_write ( … ) lnp_logical_write ( … ) wait_event (write_allow) enable tx; tx_state = active; tx_handler wait_event (write_complete) Byte

  22. Life of a Packet (Receiver) echo collision detection rx_handler lnp_integrity_byte ( byte ) Byte lnp_receive_pkt ( buffer ) lnp_addr_ handler ( … )

  23. LegOS Semaphores Task sem_wait ( ) wait_event ( )

  24. Kernel Semaphores tx_sem- only one task can transmit at a time tm_sem- only one task can touch Task Queue mm_sem- malloc needs to be memory atomic

  25. Other Topics • GCC Stack Frame and Subroutine Calling • Memory Management • Dealing with Priority Inversion • Communicating with Sensors and Motors

  26. The End

More Related