-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit af2b1b2
Showing
21 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Submodule xv6
added at
fd7629
Binary file not shown.
Submodule xv6
added at
9e0340
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _PSTAT_H_ | ||
#define _PSTAT_H_ | ||
|
||
#include "param.h" | ||
|
||
struct pstat { | ||
int inuse[NPROC]; // whether this slot of the process process table is in use (1 or 0) | ||
int pid[NPROC]; // the PID of each process | ||
int hticks[NPROC]; // the number of ticks each process has accumulated at priority 2 | ||
int lticks[NPROC]; // the number of ticks each process has accumulated at priority 1 | ||
}; | ||
|
||
|
||
#endif // _PSTAT_H_ |
Submodule xv6
added at
122cfd
Binary file not shown.
Submodule xv6
added at
30629a
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- ./kernel/fs.c | ||
+++ ./kernel/fs.c | ||
@@ -53,15 +53,22 @@ | ||
static uint | ||
balloc(uint dev) | ||
{ | ||
- int b, bi, m; | ||
+ int b, bi, m, bound; | ||
struct buf *bp; | ||
struct superblock sb; | ||
- | ||
+ | ||
bp = 0; | ||
readsb(dev, &sb); | ||
for(b = 0; b < sb.size; b += BPB){ | ||
bp = bread(dev, BBLOCK(b, sb.ninodes)); | ||
- for(bi = 0; bi < BPB; bi++){ | ||
+ | ||
+ if(b+BPB > sb.size){ //last bitmap block | ||
+ bound = sb.size % BPB; | ||
+ } else { | ||
+ bound = BPB; | ||
+ } | ||
+ | ||
+ for(bi = 0; bi < bound; bi++){ | ||
m = 1 << (bi % 8); | ||
if((bp->data[bi/8] & m) == 0){ // Is block free? | ||
bp->data[bi/8] |= m; // Mark block in use on disk. | ||
@@ -72,7 +79,9 @@ | ||
} | ||
brelse(bp); | ||
} | ||
- panic("balloc: out of blocks"); | ||
+ | ||
+ //panic("balloc: out of blocks"); | ||
+ return 0; | ||
} | ||
|
||
// Free a disk block. | ||
@@ -409,7 +418,12 @@ | ||
n = ip->size - off; | ||
|
||
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ | ||
- bp = bread(ip->dev, bmap(ip, off/BSIZE)); | ||
+ uint sector_number = bmap(ip, off/BSIZE); | ||
+ if(sector_number == 0){ //failed to find block | ||
+ panic("readi: trying to read a block that was never allocated"); | ||
+ } | ||
+ | ||
+ bp = bread(ip->dev, sector_number); | ||
m = min(n - tot, BSIZE - off%BSIZE); | ||
memmove(dst, bp->data + off%BSIZE, m); | ||
brelse(bp); | ||
@@ -436,7 +450,13 @@ | ||
n = MAXFILE*BSIZE - off; | ||
|
||
for(tot=0; tot<n; tot+=m, off+=m, src+=m){ | ||
- bp = bread(ip->dev, bmap(ip, off/BSIZE)); | ||
+ uint sector_number = bmap(ip, off/BSIZE); | ||
+ if(sector_number == 0){ //failed to find block | ||
+ n = tot; //return number of bytes written so far | ||
+ break; | ||
+ } | ||
+ | ||
+ bp = bread(ip->dev, sector_number); | ||
m = min(n - tot, BSIZE - off%BSIZE); | ||
memmove(bp->data + off%BSIZE, src, m); | ||
bwrite(bp); | ||
|
Submodule xv6
added at
e02ce6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Operating Systems and System Programming: A Deep Dive into xv6 | ||
|
||
## Overview | ||
|
||
This repository showcases a series of projects developed as part of an Operating Systems course at KAIST, using the xv6 teaching operating system. Each project focuses on enhancing or extending various components of xv6, providing hands-on experience with operating system concepts. | ||
|
||
## Projects | ||
|
||
### 00. [Introduction to xv6](./Project0-Adding-System-Calls) | ||
![Introduction to xv6](assets/images/system-call.png) | ||
|
||
*Image sourced from [Guru99](https://www.guru99.com/system-call-operating-system.html)* | ||
|
||
Refer to the [project instructions](Project0-Adding-System-Calls/Project0.pdf) to view the list of tasks to be completed. | ||
<details> | ||
<summary>Project Description</summary> | ||
This initial project introduces xv6, a teaching operating system used in the MIT Operating Systems course. The project involved gaining familiarity with the xv6 architecture and adding basic system calls to extend its functionality. | ||
</details> | ||
|
||
### 01. [Kernel Threading](./Project1-Kernel-Threading) | ||
![Kernel Threading](assets/images/OS-Kernel-Threading.png) | ||
|
||
*Image sourced from [Scaler](https://www.scaler.com/topics/user-level-threads-and-kernel-level-threads/)* | ||
|
||
Refer to the [project instructions](Project1-Kernel-Threading/Project1.pdf) to view the list of tasks to be completed. | ||
<details> | ||
<summary>Project Description</summary> | ||
Implemented kernel threading in xv6 by creating kernel threads using `clone()` and `join()` system calls. Additionally, a user-level thread library was developed with functions such as `thread_create()`, `lock_acquire()`, and `lock_release()`. | ||
</details> | ||
|
||
### 02. [Process Scheduler](./Project2-Process-Scheduler) | ||
![Process Scheduler](assets/images/OS-Process-Scheduler.png) | ||
|
||
*Image sourced from [Scaler](https://www.scaler.com/topics/operating-system/cpu-scheduling/)* | ||
|
||
Refer to the [project instructions](Project2-Process-Scheduler/Project2.pdf) to view the list of tasks to be completed. | ||
<details> | ||
<summary>Project Description</summary> | ||
Developed a priority-based process scheduler for xv6. This scheduler assigns different priority levels to processes, ensuring higher-priority processes receive more CPU time compared to those with lower priority. | ||
</details> | ||
|
||
### 03. [Null Pointer Dereferences and Shared Memory](./Project3-NullPtr-Dereferences-and-Shared-Memory) | ||
![Nullptr Dereferences and Shared Memory](assets/images/OS-Nullptr-Dereferences-Shared-Memory.png) | ||
|
||
*Image sourced from [MITRE CWE](https://cwe.mitre.org/data/definitions/476.html)* | ||
|
||
Refer to the [project instructions](Project3-NullPtr-Dereferences-and-Shared-Memory/Project3.pdf) to view the list of tasks to be completed. | ||
<details> | ||
<summary>Project Description</summary> | ||
Enhanced xv6 by adding mechanisms to handle null pointer dereferences, ensuring that any process attempting to dereference a null pointer is terminated immediately. Also implemented shared memory functionality, complete with system calls for managing and tracking shared memory usage across processes. | ||
</details> | ||
|
||
### 04. [Filesystem Optimization](./Project4-Filesystem-Optimization) | ||
![Filesystem Optimization](assets/images/OS-Filesystem-Optimization.png) | ||
|
||
*Image sourced from [UNIX v6/xv6 Book](https://pekopeko11.sakura.ne.jp/unix_v6/xv6-book/en/File_system.html)* | ||
|
||
Refer to the [project instructions](Project4-Filesystem-Optimization/Project4.pdf) to view the list of tasks to be completed. | ||
<details> | ||
<summary>Project Description</summary> | ||
Optimized the xv6 filesystem to enhance performance when handling small files. This project involved modifying the filesystem's data structures and algorithms to reduce overhead and improve efficiency for operations involving small files. | ||
</details> | ||
|
||
## Resources | ||
|
||
- [Book of xv6 (PDF)](assets/xv6book.pdf) | ||
- [Operating System Lecture Slides - KAIST (Merged PDF)](assets/EE415_Operating_Systems_Slides_merged.pdf) | ||
- [Course Syllabus](./assets/Syllabus.pdf) | ||
|
||
### Note | ||
|
||
This project was organized with the aim of demonstrating my past experience with operating systems and their low-level operations, both as a reference for myself and to showcase my skills to potential future employers. Although I uploaded this after graduation, ***the work reflects projects I completed during my master's studies.*** I believe it's important to maintain a well-documented digital footprint, especially since a recruiter once inquired about my experience with low-level concepts. |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.