Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Relazione SO

Relazione SO

Ratings: (0)|Views: 73|Likes:
Published by Gino Cappelli

More info:

Published by: Gino Cappelli on Nov 02, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Kaya Kernel – phase 2
Gino Cappelli – Andrea Melis – Andrea Catalini
: This files contains all global variables defined as
this means that all filesthat include globalvar.e can access these variables.
:It includes globalvar.e and contains the variables declaration. initial.e,interrupts.e, exceptions.e, scheduler.e and syscalls.e include globalvar.e.
:In this files are initialized all global variables and finally the scheduler is called.An important task done in this file consists in the starting of first process, allfield of the new process are initialized and finally it's added to the
ready queue
. The ready queue (structlist_headreadyQueue) contains all processes in thesystem: each new process is added on the tail of the ready queue by thescheduler. Each process in the system (apart the current process that is placedin the
variable) is either in the ready queue or blocked on asemaphore (device semaphore or an external semaphore).An other task: the four new Areas in the ROM Reserved Frame are populated.
: This files contains syscalls implementation:
SYS1 (CREATEPROCESS):Alloc a processcontrol block for the newprocess and, after initialized, add it to the ready queue.
SYS2 (TERMINATEPROCESS): Terminate a process.
SYS3 (VERHOGEN): Perform aV() operationon a semaphore passed ininput.
SYS4 (PASSERN): Perform aP() operationon a semaphore passed ininput.
SYS5 (GETPID): Return thepid of the current process.
SYS6 (GETCPUTIME): Return the time of cpu used by the processfrom it'sstart moment.
SYS7 (WAITCLOCK): Perform aP() on the pseudoClockTimersemaphore.
SYS8 (WAITIO): Perform aP() on a devicesemaphore and return thedevice status register of that device. V() it's done by the interrupt handlerevery 100 microseconds.
SYS9 (GETPPID): Return thepid of the parent.
SYS10-11-12 (SPECTLBVECT-SPECPGMVECT-SPECSYSVECT): Callingprocess attemps to (re)define (indicate) it's own handler for tlb (programtrap-sysbp) exceptions.
:We usefour array of semaphores, one array for each type of device(terminal, disk, tape, printer). Plus one semaphore for interval timer (thepseudoClockTimersemaphore). Every array has eight semaphores sincethere are max eight line for each device. Actually for theterminal we usea matrix 8x2: eight rows for each available line and two coloumns, onefor the receive and another one for the trasmission. These semaphores are defined in globalvar.c and can be accessedthrough globalvar.e.
It would have been possible to use a uniquearray of semaphores, but we've used four separate arrays for readability and simplicity 
: The management of the pid it has been made in a way to make efficientthe calculation of the pointer at the structure pcb_t, so in O(1) instead of O(n).It has created an Array of pid of length Maxpid , where each index of thearray corresponds at a pointer at process. The SYS1 acts through a counter ( pidcount ) to assign the correct pid atthe process and to insert in base at the index the pointer at processmade in the chart of the pid.Sure enough they increase the pidcount before they assign it. The SyS2 acts instead, once that you have in a great time the pointer atprocess, for reset a NULL the cell of the array that corresponds him(this option is managed by the function (massacre) ).
Finally always the SYS1 manages the situation if the counter pidcountarrives at MAXPID.In this case the SYS1 provides creating the first cell empty of the array of the pid and to assign it at the process created.
:Whenever a SYSCALL 6 is called, the kernel must be able to return theelapsed time of cpu used by the calling process. To accomplish this taskwe update an integer (unsigned integer) in the process control block of the process, in this way we can return it in every moment. In particularwe update this value before each SYS6 (because it couldn't be perfectlyupdated at that time) and in the scheduler.An other problem is raised by the interval timer, infact we must perform aV() operation on the pseudoClockTimerevery 100 microseconds.We usetwo global variables (intervalFlag, a boolean, andelapsedTime, an integer): every time the execution is passed to the schedulerit updateelapsedTime with the amount of time elapsedfrom the last time that theexecution was passed there. If elapsedTime reaches 100 microseconds,intervalFlag is setted. In this way theinterrupt timer can know if performthe V() on on the pseudoClockTimer seeing the intervalFlag.
: This file contains the sysbk exception handler, it handle each type of systemcall:
SYS1: Execute a SYS1 andcontinue with the current process.
SYS2: Terminate a process and all it's progeny. In case of success return0, -1 otherwise. If the process has been terminatedload next process.
SYS3: Perform a V() operation on a semaphore and thencontinue withcurrent process.
SYS4: Perform the P() operation: if the process must be blocked.(semaphore value < 0)call the scheduler with the blocking mode(see
), otherwise continue with the current process.
SYS5: Return the pid andcontinue with the current process.
SYS6: Like SYS5,continue with the current processafter the syscall.
SYS7: Perform a P() on the pseudoclockTimer, so if the process must beblocked call the scheduler with theblocking mode, otherwisecontinue/load the current process.
SYS8: Like SYS7 but on a semaphore device.
SYS9: Return the pid of the parent andcontinue with the current process.
SYS10-11-12: In case of successcontinue with the current process,otherwise the current process has been terminated so continue with nextprocess in ready queue.
All these three functions do the same actions:
If the offending process has issued a SYS10-11-12save the new oldarea in the current process and "pass up" the handling of theexception.
 Terminate the current process otherwise.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->