Skip to content

Commit

Permalink
Updated the Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam8387 committed Feb 23, 2023
1 parent 10ef943 commit ae5c2c0
Show file tree
Hide file tree
Showing 178 changed files with 12,868 additions and 0 deletions.
28 changes: 28 additions & 0 deletions assignment-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Assignment 2
## CS1217 Operating Systems (Spring 2023)
---

### Setting up Git on your Virtual Machines

You will need a Unix environment for this (MacOS, or Linux).

Follow the sections **Generating a new SSH key** and **Adding your SSH key to the ssh-agent** from [this link](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent), and then follow the section **Adding a new SSH key to your account** from [this link](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).

Make sure that you do this with the same GitHub Account that you're using to access the assignment.

Finally, you will have to take one last step. Execute the following command on your Terminal (copy-paste this, because the placements of the apostrophes are important):

```
echo "Host github.com
Hostname ssh.github.com
Port 443" >> ~/.ssh/config
```

### Cloning this Repository

1. There will be a big green button saying *Code* at the top of the page. Click that, click on *Local* and then click on *SSH*. Copy the link that is shown there (it should start with something like ```git@github.com:...```).
2. Open a Terminal on your VM, and run the command ```git clone [SSH URL]``` where ```[SSH URL]``` is what you copied in Step 1.
3. Run ```ls```, and you will be able to see the name of the directory that the repository got cloned to.
4. Run ```cd [DIRECTORY NAME]``` where ```[DIRECTORY NAME]``` is the name of the repository directory that you saw in Step 3.

Those are all the cloned files. If you're using a Desktop Version of Ubuntu, you will be able to find this cloned folder in your Home directory. Use these files during the assignment.
Binary file added assignment-2/cpu
Binary file not shown.
Binary file added assignment-2/cpu-print
Binary file not shown.
22 changes: 22 additions & 0 deletions assignment-2/cpu-print.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>

int main(int argc, char *argv[])

{
unsigned int i;
int count = 0;
struct timeval tv;

while(1)
{
for(i = 0; i < 1000000; i++)
{
gettimeofday(&tv, NULL);
printf("%u sec, %u usec\n", tv.tv_sec, tv.tv_usec);
}
count++;
printf("round %d complete\n", count);
}
}
18 changes: 18 additions & 0 deletions assignment-2/cpu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[])

{
unsigned int i,j;
while(1)
{
j = 1;
for(i = 1; i <= 10; i++)
{
j = j*i;
}
}
}


Binary file added assignment-2/disk
Binary file not shown.
42 changes: 42 additions & 0 deletions assignment-2/disk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <unistd.h>
#include <stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>

#define FNAME_SIZE 100
#define MAX_FILE_NO 10000
#define BLOCK_SIZE 1024

int main(int argc, char *argv[])
{

int n, file_no;
FILE *fp;
char dest_file_name[FNAME_SIZE];
char buf[BLOCK_SIZE];

while(1)
{
file_no = rand() % MAX_FILE_NO;

bzero(dest_file_name, FNAME_SIZE);
sprintf(dest_file_name, "files/foo%d.txt", file_no);

fp = fopen(dest_file_name, "rb");
if (fp == NULL) {
perror("Can't open dest file");
exit(1);
}

bzero(buf,BLOCK_SIZE);
while ( (n = (int)fread( buf, 1, BLOCK_SIZE, fp )) > 0)
{
//do nothing with the read data;
bzero(buf,BLOCK_SIZE);
}

fclose(fp);
}
}
Binary file added assignment-2/disk1
Binary file not shown.
43 changes: 43 additions & 0 deletions assignment-2/disk1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include<stdlib.h>

#define FNAME_SIZE 100
#define MAX_FILE_NO 10000
#define BLOCK_SIZE 1024

int main(int argc, char *argv[])
{

int n, file_no;
FILE *fp;
char dest_file_name[FNAME_SIZE];
char buf[BLOCK_SIZE];

while(1)
{
//file_no = rand() % MAX_FILE_NO;
file_no = 0;

bzero(dest_file_name, FNAME_SIZE);
sprintf(dest_file_name, "files/foo%d.txt", file_no);

fp = fopen(dest_file_name, "rb");
if (fp == NULL) {
perror("Can't open dest file");
exit(1);
}

bzero(buf,BLOCK_SIZE);
while ( (n = (int)fread( buf, 1, BLOCK_SIZE, fp )) > 0)
{
//do nothing with the read data;
bzero(buf,BLOCK_SIZE);
}

fclose(fp);
}
}
6 changes: 6 additions & 0 deletions assignment-2/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
for i in range(10000):
file_name = f"foo{i}.txt"
file_size = 2*1024*1024 #size in Bytes
with open(file_name, "wb") as f:
f.write(os.urandom(file_size))
16 changes: 16 additions & 0 deletions assignment-3/.cvsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.asm
*.d
*.sym
_*
kernel
user1
userfs
usertests
xv6.img
vectors.S
bochsout.txt
bootblock
bootother
bootother.out
parport.out
fmt
4 changes: 4 additions & 0 deletions assignment-3/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
((c-mode
(indent-tabs-mode . nil)
(c-file-style . "bsd")
(c-basic-offset . 2)))
27 changes: 27 additions & 0 deletions assignment-3/.gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set $lastcs = -1

define hook-stop
# There doesn't seem to be a good way to detect if we're in 16- or
# 32-bit mode, but in 32-bit mode we always run with CS == 8 in the
# kernel and CS == 35 in user space
if $cs == 8 || $cs == 35
if $lastcs != 8 && $lastcs != 35
set architecture i386
end
x/i $pc
else
if $lastcs == -1 || $lastcs == 8 || $lastcs == 35
set architecture i8086
end
# Translate the segment:offset into a physical address
printf "[%4x:%4x] ", $cs, $eip
x/i $cs*16+$eip
end
set $lastcs = $cs
end

echo + target remote localhost:26000\n
target remote localhost:26000

echo + symbol-file kernel\n
symbol-file kernel
27 changes: 27 additions & 0 deletions assignment-3/.gdbinit.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set $lastcs = -1

define hook-stop
# There doesn't seem to be a good way to detect if we're in 16- or
# 32-bit mode, but in 32-bit mode we always run with CS == 8 in the
# kernel and CS == 35 in user space
if $cs == 8 || $cs == 35
if $lastcs != 8 && $lastcs != 35
set architecture i386
end
x/i $pc
else
if $lastcs == -1 || $lastcs == 8 || $lastcs == 35
set architecture i8086
end
# Translate the segment:offset into a physical address
printf "[%4x:%4x] ", $cs, $eip
x/i $cs*16+$eip
end
set $lastcs = $cs
end

echo + target remote localhost:1234\n
target remote localhost:1234

echo + symbol-file kernel\n
symbol-file kernel
24 changes: 24 additions & 0 deletions assignment-3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.asm
*.d
*.sym
_*
##############
# *.img
# *.out
# *.o
# mkfs
# entryother
# initcode
##############
kernel
user1
userfs
usertests
xv6.img
vectors.S
bochsout.txt
bootblock
bootother
bootother.out
parport.out
fmt
7 changes: 7 additions & 0 deletions assignment-3/BUGS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
formatting:
need to fix PAGEBREAK mechanism

sh:
can't always runcmd in child -- breaks cd.
maybe should hard-code PATH=/ ?

24 changes: 24 additions & 0 deletions assignment-3/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The xv6 software is:

Copyright (c) 2006-2018 Frans Kaashoek, Robert Morris, Russ Cox,
Massachusetts Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Loading

0 comments on commit ae5c2c0

Please sign in to comment.