Programming - Multitasking in DNA OS.

 A little about the new concept of the Matrix               
 yu ZET-9                            
                                                                
First, just in case, let me remind you that MATRIX = systemDNA +    
multitasking, i.e. all disk requests from Matrix applications
are performed using function calls DNA. This has been the case since about 2006
year.                                                           
                                                                
In the latest versions with the old concept, 50% of the processor     
time allocated for disk operations (SYSTEM process), 25%  
to the graphics subsystem (which displays text on the screen -     
XWIND process) and 25% for all processes that do not sleep. This     
not good - it turns out slowly, and you can see how the screen is updated. 
The new concept focuses on fast work with graphical       
functions by abandoning preemptive multitasking (incomplete
refusal - see below) in favor of cooperative multitasking       
(for user processes only).As a result, it will work quickly as follows.       
                                                                
XWIND loads a new process to address #C000 (memory page   
asks SYSTEM, opens and reads the process file through SYSTEM),
takes the address of the main window of this process from the title and displays 
its window onto the screen. Next, XWIND marks in the cell that it is running   
the process with PID number such and such transfers control to #C000 - 
type CALL INIT. The process performs initialization and returns    
management. If the process has not returned control, but has already occurred  
interrupt, then the interrupt handler calls the BACKGROUND TASK    
XWIND process, which polls the keyboard/mouse, retypes   
cursor, then checks and sees that it is not XWIND that is working, but       
process with PID number. She sets a flag and remembers the PID         
separately, and at the next interrupt checks the PID, and if      
sees that the same process is still running, then she copies  
saved registers of this process into a table and changes the address    
return to the entry to the XWIND process procedure. Then he rules again  
XWIND.                                                          
                                                                
When you hover your mouse over a window object and click             
left/middle/right (or just keys on the keyboard) XWINDchecks whether this process is running (i.e. that it was interrupted 
last time). If yes, then let him work (maximum two   
frame, after which it will be interrupted again). If the process is not  
is executed, takes the address of the processing procedure from the window title  
impact on this particular window object - again indicates    
cell that the process with PID is running, puts it in the mailbox      
process this event (click) and does CALL ADR_RUTINE. Process
does what is needed and returns (or does not return) control. 
Immediately after this, XWIND checks the process mailbox and      
executes the request (if there is one) - for example, download a file.     
                                                                
To download a file (and generally perform any disk operations)
XWIND places a message in the mailbox of the SYSTEM process. When     
When the interrupt arrives, the handler checks this and starts          
switch processes (XWIND/SYSTEM) As a result, each of them 
now given 50% of CPU time. And before 100%      
time was given to the XWIND process, and from its time it gave   
work for the user process.                               
                                                                
Once the SYSTEM process has completed a disk operation, it no longer
is called, and then XWIND works 100% of the time again          
(inwhich includes the operating time of user processes).       
XWIND can also set the priority for the SYSTEM process in the form   
number of frames (0..7), after which they switch to       
SYSTEM:                                                         
                                                                
0 - 100% SYSTEM works until it loads everything it needs        
1 - 50%                                                        
3 - 25%                                                        
7 - SYSTEM will only work every 8th frame (this is12.5%   
CPU time)                                             
                                                                
If suddenly the user did not press or move anything, then XWIND gives      
be executed by interrupted processes, one at a time. And after each 
They are again tested for impact on the part of the user. Yes 
impact - take the address and CALL ADR_RUTIN from the window title.   
No impact - run (restoring registers) the following 
interrupted process, if any.                              
                                                                
Well, when you click outside the window of this(active) process   
he is given a message: “the process has become inactive,” and to him,   
whose window was clicked - “the process has become active”, we display this other   
window to the foreground (without brakes and switching to other    
processes), and everything repeats itself.                                   
                                                                
This is how everything will happen - as a result, frame
scroll, and show animation, and quickly print sprites via       
stack, because in fact (in the absence of disk requests)   
only ONE XWIND process is running - which can handle two screens 
use, and 16 color mode. The only thing I don’t know is about   
digital sound: if you play it, the arrow will not move,
or there will be clicks.                                           

Share your thoughts about the article