Skip to content

Refactor README for clarity and add coding tasks#1

Open
shivangjhalani wants to merge 1 commit into
mainfrom
shivangjhalani-patch-2
Open

Refactor README for clarity and add coding tasks#1
shivangjhalani wants to merge 1 commit into
mainfrom
shivangjhalani-patch-2

Conversation

@shivangjhalani
Copy link
Copy Markdown
Collaborator

Updated formatting for clarity and added code tasks for inode exploration and hard-link finding.

Updated formatting for clarity and added code tasks for inode exploration and hard-link finding.
Copilot AI review requested due to automatic review settings April 12, 2026 18:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the lab README to improve clarity and adds new hands-on coding tasks around inodes/hard links, RAID reconstruction, FAT traversal, and page-cache behavior.

Changes:

  • Added new C “Code Task” exercises: inode/link exploration, hard-link finder, RAID reconstruct, FAT seek, and a page-cache benchmark.
  • Updated markdown formatting/emphasis and adjusted some directory-scaling parameters (e.g., 5000 → 500 files).
  • Reworked later sections by removing swap/journaling content and introducing a Page Cache section, plus updated the submission checklist accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment on lines +148 to +151
int fd = open(orig, O_CREAT | O_WRONLY | O_TRUNC, 0644);
write(fd, "inode exploration\n", 18);
close(fd);

Comment thread README.md
Comment on lines +155 to +157
// TODO 1: Create a hard link (link()) from orig → hard.
// Create a symbolic link (symlink()) from orig → soft.

Comment thread README.md
File write path:
process → write() → copy into page cache (dirty page) → return immediately
↓ (background)
pdflush writes dirty pages to disk
Comment thread README.md
Comment on lines +792 to +793
# Drop ALL cached file data from RAM, then run immediately
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
Comment thread README.md
Comment on lines +740 to +757
// TODO: Allocate the read buffer.
// O_DIRECT requires the buffer address to be aligned to 4096 bytes —
// use posix_memalign(&buf, 4096, BUF_SIZE). Why does the kernel require
// this alignment? (Think about how O_DIRECT transfers data to the device.)
void *buf;
posix_memalign(&buf, 4096, BUF_SIZE);

struct timespec t0, t1;
clock_gettime(CLOCK_MONOTONIC, &t0);

ssize_t n;
long total = 0;
while ((n = read(fd, buf, BUF_SIZE)) > 0)
total += n;

clock_gettime(CLOCK_MONOTONIC, &t1);
close(fd);
free(buf);
Comment thread README.md
Comment on lines +750 to 763
ssize_t n;
long total = 0;
while ((n = read(fd, buf, BUF_SIZE)) > 0)
total += n;

clock_gettime(CLOCK_MONOTONIC, &t1);
close(fd);
free(buf);

#define MB (1024UL * 1024)

int main(void) {
// Allocate and touch 128 MB to create memory pressure
char *region = malloc(128 * MB);
if (!region) { perror("malloc"); return 1; }
memset(region, 'S', 128 * MB);

printf("Allocated 128 MB. PID: %d\n", getpid());
char cmd[128];
snprintf(cmd, sizeof(cmd),
"grep -E 'VmRSS|VmSwap' /proc/%d/status", getpid());
system(cmd);
printf("\nSwap usage:\n");
system("swapon --show");

free(region);
return 0;
double elapsed = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec) / 1e9;
printf(" %ld bytes in %.4f s → %.1f MB/s\n",
total, elapsed, (total / (1024.0 * 1024.0)) / elapsed);
return elapsed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants