This commit is contained in:
2025-02-19 00:57:08 +00:00
parent 3981fe238d
commit ddff0a6e3f
5 changed files with 92 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
{
"name": "Default Linux Universal",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/universal:2-linux"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char *argv[])
{
char command[80];
char exec_command[82];
while (1)
{
read(0, command, 80); // read from terminal
command[strcspn(command, "\n")] = 0; // remove newline character
strcpy(exec_command, "./");
strcat(exec_command, command);
char *args[]={exec_command, NULL}; // Setup arg vector
int ret = fork(); // Fork
if (ret) {
wait(0);
// continue on the loop
} else {
printf("Executing Program: %s\n", args[0]);
execv(args[0], args);
perror("execv failed"); // if fails bomb out and print error
exit(0);
}
}
}
+32
View File
@@ -0,0 +1,32 @@
HW1
COS331
NICHOLAS PEASE
18 FEB 2025
-----------------------------------------------
1) The system call table stores the addresses of the memory in which the system call code lives. When a system call is executed, it is looked up against this table, its address copied into PC, and execution transfered
2) System calls are provided to allow programmers a simplier method of accessing key operating system functions
3) A trap instruction is used to cause a software interrupt. This is useful for switching the execution mode between user and kernal
4) A divide by zero error is non maskable as there is no way to continue with the operatuib since the hardware cannot handle it
5) The last register stored in a context switch is the PC register as it holds the return address to return to
6) In a single CPU system, the Os is idling as the user process executes as it has the processor for that duration of time.
7) The process remains in memory stagnant while it is not executing. The instructions are unloaded from the CPU, but the source of those instructions remains for whenever the process is picked back up, or terminated. This structure is a Process Control Block (PCB)
8) The operating system, via system calls and other mechanisms, places limitations on the memory and what a particular program is able to access. Without these limitations, nothing would ensure that a process stays within its own space.
9) 5 major activities of an operating system regarding process management are process creation, termination, scheduling, synchronization, communication and management
10) 3 major activities of an OS regarding memory management are memory allocation, swapping and paging
11) a, b, d
12)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
int ret = fork();
if (ret) {
printf("I am the parent\n");
} else {
printf("I am the child\n");
}
}
+7 -7
View File
@@ -1,7 +1,7 @@
## cos331-hw1 ##
[![](https://gitea-actions.nicholaspease.com/actions/umaine-npease/cos331-hw1/badge?label=build&style=flat&branch=main)](https://gitea-actions.nicholaspease.com/latest-log?branch=main)
[![](https://drone.nicholaspease.com/api/badges/umaine-npease/cos331-hw1/status.svg)](https://drone.nicholaspease.com/umaine-npease/cos331-hw1)
[![](https://wakaapi.nicholaspease.com/api/badge/LAX18/interval:any/project:cos331-hw1)](https://wakaapi.nicholaspease.com/summary?interval=any&project=cos331-hw1)
![](https://server1.nicholaspease.com/badges/cloc/npease/cos331-hw1.svg)
<hr>
## cos331-hw1 ##
[![](https://gitea-actions.nicholaspease.com/actions/umaine-npease/cos331-hw1/badge?label=build&style=flat&branch=main)](https://gitea-actions.nicholaspease.com/latest-log?branch=main)
[![](https://drone.nicholaspease.com/api/badges/umaine-npease/cos331-hw1/status.svg)](https://drone.nicholaspease.com/umaine-npease/cos331-hw1)
[![](https://wakaapi.nicholaspease.com/api/badge/LAX18/interval:any/project:cos331-hw1)](https://wakaapi.nicholaspease.com/summary?interval=any&project=cos331-hw1)
![](https://server1.nicholaspease.com/badges/cloc/npease/cos331-hw1.svg)
<hr>