Skip to content
Merged
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: 3 additions & 0 deletions chapters/io/file-descriptors/drills/tasks/buffering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ We'll checkout how effective buffering is in `libc` and then we'll do it ourselv
Wrote 1048576 bytes to test-file.txt in 38 ms
```

If possible, try to manually test your implementation.
Use `./checker.sh` only when you are sure of your result.

Buffering achieves dramatic performance gains, reducing read times by **98%** and write times by **99.8%** in this example!
This demonstrates the power of buffering, even though it’s an extreme case.

Expand Down
9 changes: 8 additions & 1 deletion chapters/io/file-descriptors/drills/tasks/mmap_cp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copy a File with `mmap()`

Navigate to `file-descriptors/drills/tasks/mmap_cp` and run `make` to generate `support`.
Enter the `mmap_cp/` directory in the lab archive (or `chapters/io/file-descriptors/drills/tasks/mmap_cp` if you are working directly in
the repository), run `make skels`, then enter `support/`.
Run through the practice items below.
As you know `mmap()` can map files in memory, perform operations on them, and then write them back to the disk.
Let's check how well it performs by comparing it to the `cp` command.
The benchmarking is automated by `benchmark_cp.sh` so focus on completing `mmap_cp.c` for now.
Expand All @@ -16,6 +18,11 @@ make: Nothing to be done for 'all'.
Test PASSED (File copies are identical)
```

To test your implementation, navigate to the `mmap_cp/support/src` folder.
Run `make` to compile the code and test it manually with files generated by you.

When you think your code is correct, go to `mmap_cp/support/test` and run `checker.sh` to validate your solution.

1. Open `mmap_cp.c` and complete the TODOs to map the files in memory and copy the contents.
Do not forget to clean up by unmapping and closing the files.

Expand Down
9 changes: 8 additions & 1 deletion chapters/io/file-descriptors/drills/tasks/my-cat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# My `cat`

Navigate to `chapters/io/file-descriptors/drills/tasks/my-cat/support/src` and checkout `my_cat.c`.
Enter the `my_cat/` directory in the lab archive (or `chapters/io/file-descriptors/drills/tasks/my_cat` if you are working directly in
the repository), run `make skels`, then enter `support/`.
Run through the practice items below.
We propose to implement the Linux command `cat` that reads one or more files, **concatenates** them (hence the name `cat`), and prints them to standard output.

1. Inside the `tests/` directory, you will need to run `checker.sh`. The output for a successful implementation should look like this:
Expand All @@ -18,6 +20,11 @@ Good job!
----------------------------------------
```

To test your implementation, navigate to the `mmap_cp/support/src` folder.
Run `make` to compile the code and test it manually with files generated by you.

When you think your code is correct, go to `mmap_cp/support/test` and run `checker.sh` to validate your solution.

1. Implement `rread()` wrapper over `read()`.

`read()` system call does not guarantee that it will read the requested number of bytes in a single call.
Expand Down
9 changes: 8 additions & 1 deletion chapters/io/ipc/drills/tasks/anon-pipes/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Anonymous Pipes Communication

Navigate to `chapters/io/ipc/drills/tasks/anon-pipes` and run `make` to generate the `support/` folder.
Enter the `anon_pipes/` directory in the lab archive (or `chapters/io/ipc/drills/tasks/anon-pipes` if you are working directly in
the repository), run `make skels`, then enter `support/`.
Run through the practice items below.
In this exercise, you'll implement client-server communication between a parent and a child process using an anonymous pipe.
The parent will act as the sender, while the child acts as the receiver, with both processes sharing messages through the pipe.
Since pipes are unidirectional, each process should close the end of the pipe it does not use.
Expand All @@ -15,6 +17,11 @@ Test for short string ........... PASSED
Test for long string ........... PASSED
```

To test your implementation, navigate to the `mmap_cp/support/src` folder.
Run `make` to compile the code and test it manually with files generated by you.

When you think your code is correct, go to `mmap_cp/support/test` and run `checker.sh` to validate your solution.

1. Use the [`pipe()` syscall](https://man7.org/linux/man-pages/man7/pipe.7.html) to create the pipe.
Remember, the first file descriptor (`fds[0]`) is the read end, and the second (`fds[1]`) is the write end, similar to how `stdin` and `stdout` are represented by file descriptors `0` and `1`.

Expand Down
1 change: 1 addition & 0 deletions chapters/io/overview/reading/lab9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The contents of the lab are located in the [lab archive](https://github.com/cs-pub-ro/operating-systems/raw/refs/heads/lab-archives/Lab_9_File_Descriptors.zip) and in the [GitHub repository](https://github.com/cs-pub-ro/operating-systems).
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ lab_structure:
- title: Lab 9 - File Descriptors
filename: lab9.md
content:
- reading/lab9.md
- tasks/my-cat.md
- tasks/mmap_cp.md
- tasks/anon-pipes.md
Expand Down