au-ts / lionsos

A secure, fast, and adaptable OS based on the seL4 microkernel
https://lionsos.org
BSD 2-Clause "Simplified" License
84 stars 12 forks source link

Support for Micropython Keyboard Interrupts #73

Open Kswin01 opened 4 months ago

Kswin01 commented 4 months ago

This PR adapts the micropython port to support keyboard interrupts. We buffer the input characters from the sDDF serial subsystem in internal micropython buffers, so that we can process interrupt chars as they come in. We then read characters from our internal buffers when reads are requested. The transmit path remains unchanged.

JE-Archer commented 4 months ago

One issue is that while inputting ^C will kill executions that wait for IO, it won't do anything for executions that don't. Example:

Inputting ^C will kill

async def f():
    await asyncio.sleep(10)
asyncio.run(f())

but won't kill

for i in range(100000):
    print(i)
Kswin01 commented 3 months ago

One issue is that while inputting ^C will kill executions that wait for IO, it won't do anything for executions that don't. Example:

Inputting ^C will kill

async def f():
    await asyncio.sleep(10)
asyncio.run(f())

but won't kill

for i in range(100000):
    print(i)

That's correct, if we never switch to the t_event co-routine, we will never process input and therefore not receive the keyboard interrupts. We couldn't think of a great way to deliver these characters within the current design.