littlekernel / lk

LK embedded kernel
MIT License
3.11k stars 613 forks source link

[kernel] Add ability for port_write to work in IRQ context #284

Open travisg opened 3 years ago

travisg commented 3 years ago

It seems that port_write() is nearly okay to use at IRQ context but since it hard reschedules at the bottom it'll get lost. Either we need to plumb through bool resched or switch to a smarter scheme to avoid rescheduling issues with primitives.

Adarsh2425 commented 10 months ago

@travisg, thank you for bringing up this issue. Ensuring that port_write() can work effectively in IRQ contexts is crucial for improving the overall performance and reliability of the kernel.

I agree with your observation that the hard rescheduling at the end of port_write() can lead to issues in IRQ contexts. To address this concern, I would like to propose the following potential solutions:

  1. Introduce a bool resched Flag: We can add a boolean flag, resched, as you mentioned, to control the rescheduling behavior within port_write(). This flag could be set externally before calling port_write() when rescheduling is desired, ensuring that IRQ contexts are not adversely affected.

  2. Smarter Rescheduling Scheme: Exploring a more intelligent rescheduling scheme is a promising approach. This would involve reevaluating the rescheduling logic within port_write() and designing a mechanism that optimizes rescheduling based on the context.

I'm willing to contribute to the implementation of either of these solutions. However, I'd appreciate any guidance or thoughts from the community on which approach to prioritize or if there are alternative suggestions.

Looking forward to collaborating with the community on this issue to enhance the functionality of port_write() in IRQ contexts.

Best regards, adarsh