home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / noyau / noyau.asm < prev    next >
Assembly Source File  |  1994-05-18  |  2KB  |  92 lines

  1. .286
  2. .MODEL SMALL,OS_DOS
  3.  
  4. ;
  5. ;
  6. ;    DEFINITION DU PROCESSUS NOYAU : POINT D'ENTREE DU PROGRAMME
  7. ;
  8. ;
  9. ;
  10.  
  11. INCLUDE dos.inc
  12. INCLUDE types.inc
  13. INCLUDE const.inc
  14. INCLUDE etats.inc
  15. INCLUDE descript.inc
  16. INCLUDE queue.inc
  17. INCLUDE semphor.inc
  18. INCLUDE process.inc
  19. INCLUDE gestlist.inc
  20. INCLUDE donnees.inc
  21. INCLUDE code.inc
  22.  
  23. .STACK 1024     ; pile privée de pNoyau
  24.  
  25. PilePrincipal SEGMENT WORD PUBLIC 'STACK'
  26.     EXTERN  SP_PilePrincipal : WORD
  27. PilePrincipal ENDS
  28.  
  29. .DATA
  30.  
  31. TableCentrale LABEL WORD
  32.     EnCours  WORD ?    ; pointeur sur le DdP du processus ACTIF
  33.     QueueExp WORD ?    ; pointeur sur la cellule de garde de la Queue d'exploitation
  34.  
  35. TableProcessus LABEL WORD
  36.     pNoyau      PROCESSUS <{,,,TypeProcessus,ACTIF,254}> ; Processus Noyau
  37.  
  38.     pPrincipal    PROCESSUS <{,,,TypeProcessus,SUSPENDU,128},OFFSET SP_PilePrincipal,PilePrincipal,NIL>
  39.  
  40.  
  41.     qe          QUEUE     <OFFSET @data:qe,OFFSET @data:qe,,TypeQueue,OCCUPE,INFINI>
  42.  
  43.     NonPreemptif    BYTE 0  ; Le noyau est initialement préemptif
  44.     FinNoyau        BYTE ENCORE ; flag pour que pHorloge rétablisse l'ancien vecteur
  45.                 ; d'interruption
  46.     NoyauFini        BYTE ENCORE ; flag pour prévenir pNoyau qu'il peut rendre la main
  47.                 ; à MS DOS
  48.  
  49. .CODE
  50.  
  51. Noyau PROC
  52.     assume ds:@data
  53.     mov ax,@data
  54.     mov ds,ax
  55.  
  56.     lea ax,pNoyau        ; initialisation de Encours
  57.     lea si,EnCours
  58.     mov [si],ax
  59.     lea si,QueueExp        ; et de la Queue d'exploitation
  60.     mov [si],OFFSET qe
  61.  
  62.  
  63.     mov bx,OFFSET pHorloge    ; on place pHorloge dans la queue d'exploitation
  64.     call eligible
  65.     call dispatcher        ; et on lui donne la main
  66.  
  67.     mov bx,OFFSET pPrincipal    ; on place pPrincipal dans la queue d'exploitation
  68.     call eligible
  69.  
  70.     call dispatcher        ; et hop, pPrincipal s'execute (car sa priorité est
  71.                 ; plus forte).
  72.  
  73.     ; le dispatcher à rendu la main à pNoyau, donc tous les autres processus
  74.     ; sont bloqués ou terminés.
  75.     ; donc,on termine le noyau !
  76.  
  77.     mov di,offset FinNoyau    ; on demande à pHorloge de rétablir l'ancien
  78.     mov BYTE PTR [di],FIN    ; vecteur d'interruption
  79.     mov si,offset NoyauFini
  80. attente_fin:
  81.     cmp BYTE PTR [si],FIN    ; on attend.
  82.     jne attente_fin
  83.  
  84.         ; le système n'est plus multitache.
  85.         ; on retourne au dos
  86.  
  87.     Mov ax,4C00h
  88.     Int 21h        ; on rend la main à MS DOS
  89. Noyau ENDP
  90.  
  91. END NOYAU
  92.