📜 ⬆️ ⬇️

Micronuclear Real Time OS - the necessary functionality for a simple example

What does a microkernel OS do in real-time with such a simple task as manual scanning ?
What can be a manual scan for? Suppose you need to scan a couple of dozen pages in different newspapers. And the newspapers are in the library.
Of course, you can take a regular scanner and laptop, type a stack of newspapers and slowly scan them, then cut out the necessary blocks.
And another option is to take a handheld scanner with USB connection, USB HDD or, in extreme cases, a USB flash drive, connect it with some “iQube”, representing a glamorous box with touch sides and usb connectors

If we take as an example the usual Linux kernel, then there are two types of devices - block and character .

But in our case neither the symbolic nor the block will be suitable. We need a fundamentally new type of devices, or rather, an interface for interacting with devices. Let's call it iStream.

iStream is characterized by initialization, with arguments of the frequency of information output and its volume, as well as the ability to work with memory directly (DMA).
')
How does a USB drive or a USB flash drive with iStream interface work? You can open the channel to the raw (raw) format or to the file system on this device. You can request information, for example - the maximum amount of DMA, IO (read / write speed between the device and DMA), and get some parameters.
For example, for a FAT32 file system on a USB flash drive, the DMA volume will be 16Mb, the IO speed is 0.3s. Thus, at the peak there may be 3.33 interrupts of 16Mb each. Round up to 3 and get 48Mb per second.

How does USB scanner with iStream interface work? It is initialized with the DMA memory capacity of 8MB, the minimum frequency of information reset from the scanner memory is from 0.01 s, the buffer volume that is dumped into the DMA is 16K. Thus, at a minimum, 1.5Mb per second can be reset. And if the user "vzhiknet scanner", then 8Mb will be completely clogged in a second. Consequently, the reset frequency can be much higher. If we do not take data from DMA in time, then the old information will be erased at the top of the new one, respectively, overflow cannot be allowed!

The iConvert pseudo-device works like some kind of black box — it takes as input arguments iStream, some conversion method described by a meta-marker. And at the output gives its flow. for example
iConvert (iStream (scan [0] .raw), raw2bmp) will display iStream of type bmp. Which can be written to iStream USB media.

iConvert also has its own bandwidth, which depends on the processor and free iQube RAM. The device constantly generates interrupts and reports the percentage of free resources for the current state.

And now about how this all works.
The user sticks in iQube iScanner and iFlash, comes into library, takes the newspaper and carries out the scanner on a strip
Scanner flushes buffers to DMA. iConvert - makes bmp and sends it to the USB flash drive.
If the user drives the scanner too quickly, the stream will increase from 1.5MB / s to 8MB / s.
iConvert gives an interrupt about its status. With a maximum load of 8MB / s, the device may not be enough resources after a while. The iQube system monitors this and changes the color of the cube first to yellow and to red in critical situations.

But hobby, I'll hit him and he will turn purple ? :)

Source: https://habr.com/ru/post/27490/


All Articles