Handling system calls without blocking the kernel [AVR]
Posted: Tue Jul 04, 2017 6:31 pm
Hello,
I am currently developing an operating system that runs on AVR microcontrollers. The target platform is VERY low spec -- I am trying to keep the minimum hardware requirement of an Atmega328 with 32KB of ROM and 2 KB of RAM. From reading the forum, I gather that most people on here are x86 developers. But hopefully my issue is generic enough that the architecture isn't an issue.
Thus far, I have FAT16 file system support, an ELF loader, memory allocator and a scheduler all while using less than 1 KB of kernel space RAM.
I've hit a roadblock though: system calls.
I have done a lot of searching both here and on the general web as well as reading source code of Linux and other open source operating systems but yielding no solution.
In short: When calling a blocking system call, how does one avoid blocking the kernel?
The way I am handling system calls now is that the process calls a vector at a known address and the vector adds the system call to a queue and then goes into a while() loop until the call is completed. At the same time, the kernel task looks for any outstanding system calls in the queue. It loops through the queue and does them in sequence if there are any, marks them complete and puts the result into the queue buffer. The system call vector then sees the call is completed and returns to the process with the result.
The major problem is if a blocking call like read() is performed, it blocks the kernel task so no other system calls can be performed until the system call is completed.
I'm not calling the kernel functions directly from the vector because some of the kernel functions are relatively memory hungry and I was hesitant to run them in the calling processes' stack.
Any ideas?
Thank you
I am currently developing an operating system that runs on AVR microcontrollers. The target platform is VERY low spec -- I am trying to keep the minimum hardware requirement of an Atmega328 with 32KB of ROM and 2 KB of RAM. From reading the forum, I gather that most people on here are x86 developers. But hopefully my issue is generic enough that the architecture isn't an issue.
Thus far, I have FAT16 file system support, an ELF loader, memory allocator and a scheduler all while using less than 1 KB of kernel space RAM.
I've hit a roadblock though: system calls.
I have done a lot of searching both here and on the general web as well as reading source code of Linux and other open source operating systems but yielding no solution.
In short: When calling a blocking system call, how does one avoid blocking the kernel?
The way I am handling system calls now is that the process calls a vector at a known address and the vector adds the system call to a queue and then goes into a while() loop until the call is completed. At the same time, the kernel task looks for any outstanding system calls in the queue. It loops through the queue and does them in sequence if there are any, marks them complete and puts the result into the queue buffer. The system call vector then sees the call is completed and returns to the process with the result.
The major problem is if a blocking call like read() is performed, it blocks the kernel task so no other system calls can be performed until the system call is completed.
I'm not calling the kernel functions directly from the vector because some of the kernel functions are relatively memory hungry and I was hesitant to run them in the calling processes' stack.
Any ideas?
Thank you