LegOS 0'2'4 Kernel - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

LegOS 0'2'4 Kernel

Description:

return SP of new. tm.c. tm.c. tm.c. systime.c. Prioritized Round Robin w/ Task Queue. packet_consumer ... Example: 'Stop the car when light sensor falls below value X' ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 27
Provided by: Works216
Category:

less

Transcript and Presenter's Notes

Title: LegOS 0'2'4 Kernel


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
32k RAM
16k ROM
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
LNP
MM
Program
execi
idle (min)
packet_consumer (max)
key_handler (max)
6
Timer Interrupts
1 interrupt / ms
16-bit Timer
RAM
ROM
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
Waiting
Zombie
wait_event ( )
termination
free stack (scheduler)
wake-up function (scheduler)
Running
scheduler
Dead
Sleeping
execi( ), timeslice
9
Scheduler Invocation
systime_handler ( )
yield ( )
tm.c
systime.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 gt Task priority?
Postpone Interrupt
Run Interrupt Handler
14
Interrupt Queue
When do we handle postponed interrupts?
tm_scheduler ( )
  • find new task
  • handle inter. with priority gt 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.
  • Handling of 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
CHK
DATA
F0
LEN
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
CHK
DATA
F1
LEN
DEST
SRC
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
RAM
ROM
rx_handler ( ) tx_handler ( )
rxi_vector txi_vector
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)
collision detection
echo
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
Write a Comment
User Comments (0)
About PowerShow.com