Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Martin Aigner <martin@maigner.net>
Christian Barthel <cbarthel@cs.uni-salzburg.at>
Christoph Kirsch <ck@cs.uni-salzburg.at>
Michael Lippautz <michael.lippautz@gmail.com>
Simone Oblasser <simone.oblasser@cs.uni-salzburg.at>
Simone Oblasser <simone.oblasser@cs.uni-salzburg.at>
Armin Lanhgofer <uni@langhofer.at>
79 changes: 79 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#########################################
## Assignment 0: Basic data structures ##
#########################################
https://github.com/cksystemsteaching/AOS-Winter-2015
Author: armin langhofer <uni@langhofer.at>

This is my implementation of a linked list in C*.

To Compile, please follow these steps:
======================================
1. install ubuntu 32bit lts server edition, apt-get install gcc.
2. see https://github.com/mistay/AOS-Winter-2015/tree/selfie-master for how to get selfie up and running
3. git clone repro from https://github.com/mistay/AOS-Winter-2015.git or, if pull request was accepted from
https://github.com/cksystemsteaching/AOS-Winter-2015.git
4. change into cloned directory and do the following:

$ gcc -o selife selfie.c -fno-builtin
$ touch out
$ ./selfie -c < selfie.c
$ mv out selfie.mips1
$ touch out
$ ./selfie -m 32 selfie.mips1 < linkedlist.c
mem 32MB
[OS] Terminated with 0


To Run:
=======
$ ./selfie -m 32 out
mem 32MB
d,c,b,a
d,b,a
done[OS] Terminated with 6
$

Interpretation and Explanation of what happened
===============================================
First, linkedlist.c creates some arbitrary elements:

...
head = create(0, 'a');
head = create(head, 'b');
toberemoved = create(head, 'c');
...

Then, the resulted list is printed to stdout:

d,c,b,a

Now, one element is removed:

...
remove(head, toberemoved);
...

The resulting list is printed again:
d,b,a


Some fixed chars are printed (this is an easter-egg styled 'hello world'):
done

And the application exits with exit code 6: just to clarify this application exits (and not the emulator).
Terminated with 6


Result
======
[OK] must be implemented in C*
[OK] must compile with selfie
[OK] must run on selfie
[OK alloc() ] the list must be dynamically allocated
[OK, alloc() ] every node must be dynamically allocated
[OK, create() ] inserting nodes to the list and removing nodes from the list
[OK, printll()] list iteration
[NG] Bonus: sort the list. Any way you like
[OK, Oct 14] Deadline: Oct 15, end of day


83 changes: 83 additions & 0 deletions README_ASSIGNMENT1
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
############################################################
## Assignment 1: Loading, scheduling, switching, execution #
############################################################
https://github.com/cksystemsteaching/AOS-Winter-2015
Author: armin langhofer <uni@langhofer.at>

Please note: in this example _4_ instances of count.c are loaded and executed.

To Compile, please follow these steps:
======================================
1. install ubuntu 32bit lts server edition, apt-get install gcc.
2. see https://github.com/mistay/AOS-Winter-2015/tree/selfie-master for how to get selfie up and running
3. git clone repro from https://github.com/mistay/AOS-Winter-2015.git or, if pull request was accepted from
https://github.com/cksystemsteaching/AOS-Winter-2015.git
4. change into cloned directory and do the following:

$ gcc -o selfie selfie.c
$ touch out
$ ./selfie -c < count.c
$

To Run:
=======
# setting NUM_BINARES to 1 ends up in this result:
$ ./selfie -m 32 out
out: memory size 32MB
0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYout: exiting with error code 7

# now setting NUM_BINARIES to 4, recomplile and run:
$ ./selfie -m 32 out
out: memory size 32MB
0000111122223333444455556666777788889999::::;;;;<<<<====>>>>????@@@@AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYout: exiting with error code 7
$

Interpretation and Explanation of what happened
===============================================
NUM_BINARIES is a global 'constant' in selfie.c that can be adjusted to the number of binaries that are loaded into memore as requested by assignment 1.

setting to 1 and executing a the following demo:

-- snip demo --
$ more count.c
int main() {
int i;
i=48;

// print '0' to 'Z' (in asciitable)
while (i<90) {
putchar(i);
i = i+1;
}

exit(7);
}
-- /snip demo --

leads to the output shown above.

Some notes on memory usage:
- n times memory is needed (the loadBinary() memory is copied n-1 times)
- the int* registers are copied n-1 times
- pc, reg_hi, reg_lo and ir are copied n-1 times (and organized in int* processes)

Please note: three commands are executed, then a context switch is performed. The value of three can be adusted in run() and should not affect the number of characters printed when running the demo code. I tested this for m=3 and m=4 successfully.



Result
======
[OK] Uunderstand how mipster interprets and executes binary instructions. Tipp: add your own comments to the code
[OK] mipster maintains a local state for a process (running executable), e.g., pc, registers, memory
[OK] understand the purpose of each variable and data structure
[OK] duplicate the process state n times
[OK] running mipster like: ./selfie -m 32 yourbinary should generate n instances of yourbinary in a single instance of mipster
[OK] implement preemptive multitasking, i.e., switching between the n instances of yourbinary is determined by mipster
[OK, tested for m=3 and m=4] switch processes every m instructions. 1 <= m <= number of instructions in yourbinary
[OK, see output] implement round-robin scheduling
[OK, see count.c] add some output in yourbinary to demonstrate context switching
[NG, needed more time to work on this assignment] Deadline: Oct 22, end of day




95 changes: 95 additions & 0 deletions README_ASSIGNMENT2
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
##########################################################
## Assignment 2: Memory segmentation, yield system call ##
##########################################################
This assignment deals with cooperative multitasking of n processes in mipster using a single instance of physical memory.

again, duplicate the process state n times
but, do not duplicate the whole main memory
instead, split the main memory into segments by implementing a segment table in mipster
each process has an entry in the segment table for the segment start address and segment size
design the segment table for constant time access
translate the addresses of read and write operations to memory

implement cooperative multitasking through a yield system call, i.e., a user process calling sched_yield() will cause the OS to re-schedule

implement a simple user program that demonstrates yielding, e.g, yield each time after printing a counter to the console
Deadline: Oct 29, end of day





To Compile, please follow these steps:
======================================
1. install ubuntu 32bit lts server edition, apt-get install gcc.
2. see https://github.com/mistay/AOS-Winter-2015/tree/selfie-master for how to get selfie up and running
3. git clone repro from https://github.com/mistay/AOS-Winter-2015.git or, if pull request was accepted from
https://github.com/cksystemsteaching/AOS-Winter-2015.git
4. change into cloned directory and do the following:




Compile and Run:
================
$ touch count
$ ./selfie -c count.c -o count
./selfie: this is selfie's cstarc compiling count.c
./selfie: writing code into output file count
$ gcc selfie.c -o selfie && ./selfie -l count -m 32
./selfie: loading code from input file count
./selfie: this is selfie's mipster executing count with 32MB of memory
000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYcount: exiting with error code 7
$


now with yield syscall:
$ gcc selfie.c -o selfie && ./selfie -l count -m 32
./selfie: loading code from input file count
./selfie: this is selfie's mipster executing count with 32MB of memory
0y0y0y1y1y1y2y2y2y3y3y3y4y4y4y5y5y5y6y6y6y7y7y7y8y8y8y9y9y9y:y:y:y;y;y;y<y<y<y=y=y=y>y>y>y?y?y?y@y@y@yAyAyAyByByByCyCyCyDyDyDyEyEyEyFyFyFyGyGyGyHyHyHyIyIyIyJyJyJyKyKyKyLyLyLyMyMyMyNyNyNyOyOyOyPyPyPyQyQyQyRyRyRySySySyTyTyTyUyUyUyVyVyVyWyWyWyXyXyXyYyYyYycount: exiting with error code 7


Interpretation and Explanation of what happened
===============================================
selfie's mipster loads 3 processes into its *memory.
all of the processes get 1Meg of RAM each, segmented into segments in *segmenttable.
first demo output prints result when m=6 in selfie.c (context switch after 12 execute()s).
second output demonstrates yielding (m=120): count yields each time after a char is printed.



-- snip demo --
$ more count.c
int main() {
int i;
i=48;

// print '0' to 'Z' (in asciitable)
while (i<90) {
putchar(i);
i = i+1;
sched_yield();
}

exit(7);
}
-- /snip demo --


Result
======
[OK] again, duplicate the process state n times
[OK] but, do not duplicate the whole main memory
[OK] instead, split the main memory into segments by implementing a segment table in mipster
[OK] each process has an entry in the segment table for the segment start address and segment size
[OK] design the segment table for constant time access
[OK] translate the addresses of read and write operations to memory

[OK] implement cooperative multitasking through a yield system call, i.e., a user process calling sched_yield() will cause the OS to re-schedule

[OK] implement a simple user program that demonstrates yielding, e.g, yield each time after printing a counter to the console
[NG, neede more time to work on this assignment] Deadline: Oct 29, end of day



121 changes: 121 additions & 0 deletions README_ASSIGNMENT3
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
############################################
## Assignment 3: bootstrapping the kernel ##
############################################
At the end of this assignment you will have the operating system running on top if mipster along with other processes.

implement the operating system in selfie.c and use the provided flag (-k) to execute the kernel code.
whenever a trap (e.g. a syscall instruction) or an interrupt (e.g. scheduling timer) happens, the operating is invoked instead of handling the trap or interrupt by the emulator. However, the OS cannot modify the machine state directly, i.e., modifying the memory pointer and registers array is not possible. Therefore:
provide a special system call, e.g., switch(int previous_process, int next_process) in the emulator that is invoked by the operating system only and modifies the machine state. One issue remains: after the OS invokes switch, the OS process must be reset to interrupt-trap handling mode. You can rely on the following convention: mipster starts executing a binay at address 0x0, the main method of selfie.c. Resetting the PC of the OS process to 0x0 after switch will reset the OS but not its heap and globals. The OS stack must be reset as well. Important: selfie -k must start with interrupt/trap handling. If no interrupt or trap is to be handled, the OS switches to the first ready process. If not ready process exists, the OS loads some_program.mips or terminates.

Deadline: Nov 5, end of day



Compile and Run:
================
$ touch count
$ gcc selfie.c -o selfie && ./selfie -l count -m 32
./selfie: loading code from input file count
./selfie: this is selfie's mipster executing count with 32MB of memory
KERNEL syscall_switch_from-to: 0->1
01234567_NEXTKERNEL syscall_switch_from-to: 0->2
01234567_NEXTKERNEL syscall_switch_from-to: 0->1
89:;<=>?@_NEXTKERNEL syscall_switch_from-to: 0->2
89:;<=>?@_NEXTKERNEL syscall_switch_from-to: 0->1
ABCDEFGHI_NEXTKERNEL syscall_switch_from-to: 0->2
ABCDEFGHI_NEXTKERNEL syscall_switch_from-to: 0->1
JKLMNOPQR_NEXTKERNEL syscall_switch_from-to: 0->2
JKLMNOPQR_NEXTKERNEL syscall_switch_from-to: 0->1
STUVWXYcount: exiting with error code 8
$

Interpretation and Explanation of what happened
===============================================
selfie's mipster loads 3 processes into its *memory.
the 1st process (process_id == 0) could be seen as a "kernel".
the remaining two processes are counters to demonstrate how the kernel works.

all three processes are in count.c. the switch between kernel and other procesesses is handled by
count.c. a getpid() systemcall is provided for count.c to determine if process should come up as kernel or not.

please note: as soon as exit syscall is emitted the emulator stops working (second running process is not executed to the end) but resolving this issue seems not to be the goal of this assignment.

the characters 'K','E','R','N','E','L' are sent to console to indicate that kernel is running.
the kernel then switches to the next process, e.g. when switching from 0 to pid 2 it's indicated
by: 'syscall_switch_from-to: 0->2'.

please note: a timer interrupt is simulated in run(), see snippet:
-- snip selfie --
// timer interrupt for o/s. simulates external timer. just interrupts non-os pid
if (process_id != 0) {
m = m+1;
if (m > 200) {
m = 0;

saveContext();
process_id = 0; // = O/S
loadContext();
pc = pc + 4;
}
}

-- /snip selfie --
this forces the non-process pids to switch to kernel process. the program counter has to be increased as the syscall from switching from kernel to non-kernel processes (happend before) did not return.


please note: 'N','E','X','T' indicates that the kernel code completed.

last note: as i'm working alone on all the issues and the assignments are sequent it is hard to adhere the deadlines. so i am afraid this issue is late again.

-- snip demo --
$ more count.c
int main() {
int i;
int pid;

int rr_pid;

pid = (int)getpid();

if (pid == 0 ) {
rr_pid = 0;
while (1) {

// kernel process
putchar('K');
putchar('E');
putchar('R');
putchar('N');
putchar('E');
putchar('L');

rr_pid = rr_pid + 1;
if (rr_pid > 2)
rr_pid = 1;
sched_switch(0, rr_pid);
putchar('_');
putchar('N');
putchar('E');
putchar('X');
putchar('T');


//sched_yield();
}
exit(6);
} else {
// non-kernel processes
i=48;

// print '0' to 'Z' (in asciitable)
while (i<90) {
putchar(i);
i = i+1;
}
exit(8);
}

}
-- /snip demo --


Loading