Using Fork, Multitasking Kernel-Microprocessor and Assembly Language Programming-Assignment, Exercises of Microprocessor and Assembly Language Programming

This task was assigned at Quaid-i-Azam University for Microprocessor and Assembly Language Programming course by Prof. Saleem Raza. Its main points are: Multitasking, Kernel, Fork, Stack, Queue, Index, Switch, Ascii, Bars, Interrupt, Pcb, Timer

Typology: Exercises

2011/2012

Uploaded on 08/04/2012

saqqi
saqqi 🇵🇰

4

(33)

40 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EXERCISES
1. Change the multitasking kernel such that a new two byte variable is
introduced in the PCB. This variable contains the number of turns
this process should be given. For example if the first PCB contains 20
in this variable, the switch to second process should occur after 20
timer interrupts (approx one second at default speed) and similarly
the switch from second to third process should occur after the
number given in the second process’s PCB.
2. Change the scheduler of the multitasking kernel to enque the current
process index a ready queue, and dequeue the next process index
from it, and assign it to current. Therefore the next field of the PCB is
no longer used. Use queue functions from Exercise 5.XX.
3. Add a function in the multitasking kernel to fork the current process
through a software interrupt. Fork should allocate a new PCB and
copy values of all registers of the caller’s PCB to the new PCB. It
should allocate a stack and change SS, SP appropriately in the new
PCB. It has to copy the caller’s stack on the newly allocated stack. It
will set AX in the new PCB to 0 and in the old PB to 1 so that both
threads can identify which is the creator and which is the created
process and can act accordingly.
4. Add a function in the multitasking kernel accessible via a software
interrupt that allows the current process to terminate itself.
5. Create a queue in the multitasking kernel called kbQ. This queue
initially empty will contain characters typed by the user. Hook the
keyboard interrupt for getting user keys. Convert the scan code to
ASCII if the key is from a-z or 0-9 and enque it in kbQ. Ignore all
other scan codes. Write a function checkkey accessible via a software
interrupt that returns the process in AX a value removed from the
queue. It waits if there is no key in the queue. Be aware of enabling
interrupts if you wait here.
6. Modify the multitasking kernel such that the initial process displays
at the last line of the screen whatever is typed by the user and clears
that line on enter. If the user types quit followed by enter restore
everything to normal as it was before the multitasking kernel was
there. If the user types start followed by enter, start one more rotating
bar on the screen. The first rotating bar should appear in the upper
left, the next in the second column, then third and so on. The bar
color should be white. The user can type the commands ‘white’, ‘red’,
and ‘green’ to change the color of new bars.

Partial preview of the text

Download Using Fork, Multitasking Kernel-Microprocessor and Assembly Language Programming-Assignment and more Exercises Microprocessor and Assembly Language Programming in PDF only on Docsity!

EXERCISES

  1. Change the multitasking kernel such that a new two byte variable is introduced in the PCB. This variable contains the number of turns this process should be given. For example if the first PCB contains 20 in this variable, the switch to second process should occur after 20 timer interrupts (approx one second at default speed) and similarly the switch from second to third process should occur after the number given in the second process’s PCB.
  2. Change the scheduler of the multitasking kernel to enque the current process index a ready queue, and dequeue the next process index from it, and assign it to current. Therefore the next field of the PCB is no longer used. Use queue functions from Exercise 5.XX.
  3. Add a function in the multitasking kernel to fork the current process through a software interrupt. Fork should allocate a new PCB and copy values of all registers of the caller’s PCB to the new PCB. It should allocate a stack and change SS, SP appropriately in the new PCB. It has to copy the caller’s stack on the newly allocated stack. It will set AX in the new PCB to 0 and in the old PB to 1 so that both threads can identify which is the creator and which is the created process and can act accordingly.
  4. Add a function in the multitasking kernel accessible via a software interrupt that allows the current process to terminate itself.
  5. Create a queue in the multitasking kernel called kbQ. This queue initially empty will contain characters typed by the user. Hook the keyboard interrupt for getting user keys. Convert the scan code to ASCII if the key is from a-z or 0-9 and enque it in kbQ. Ignore all other scan codes. Write a function checkkey accessible via a software interrupt that returns the process in AX a value removed from the queue. It waits if there is no key in the queue. Be aware of enabling interrupts if you wait here.
  6. Modify the multitasking kernel such that the initial process displays at the last line of the screen whatever is typed by the user and clears that line on enter. If the user types quit followed by enter restore everything to normal as it was before the multitasking kernel was there. If the user types start followed by enter, start one more rotating bar on the screen. The first rotating bar should appear in the upper left, the next in the second column, then third and so on. The bar color should be white. The user can type the commands ‘white’, ‘red’, and ‘green’ to change the color of new bars.