Question: Make a context switching operating system. To do this, we switch between three processes . These are subroutines that do different things within our system.

Make a context switching operating system.
To do this, we switch between three processes. These are subroutines that do different things within our system. For us, they will just print Process 1,Process 2, and Process 3(though) you could be more creative if you want, and prints some value that is stored in a register. This register must be re-used in all your processes to show that it has been restored.
The only interrupt that LC-3 provides us is keyboard, so any input from the keyboard will cause the program to switch which process is running.
To do this, you need to have a process control block for each of your processes. This holds metadata about your process, which allows us to restore it.
.fill process1 ; the struct for the thread is address of the code
.fill x0 ; and the current count
.fill x0 ; this PSR
.fill x0 ; their R7
You will need one of these for each process, then create an array of process control blocks.
When an interrupt is received, you must store the current process state, and restore the state of the next process.
This all prints out very fast! Put a sleep in your processes to stop them from printing so quickly
and R1,R1,#1
sleeploop
add R1,R1,#1
brnp sleeploop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!