Announcements
03/17: Exam solution and Lab7 released
- The exam solution is released on Canvas.
- Review the provided answers and estimate your score.
- Your official exam grade will be released on Canvas next Monday (03/31).
- We will not return your exam. If there is a discrepancy between your estimated score and the posted grade, contact us.
- Lab7 is released and will be due in two weeks (04/07/2025, 23:59).
- This is the last lab. (finally!)
- The instructor will go through the design of our file system in the next lecture.
- You should get familiar with the lab before the lecture. (start early!)
03/17: Final project released
- Final project is released.
03/11: Sample exam and Lab6 released
- We release a sample exam with solutions on Canvas.
- Lab6 is released and will be due in two weeks (03/24/2025, 23:59).
02/27: recorded lectures released
- All recorded lectures of virtual memory are released on Canvas.
- Notes, a handout, and scribbles are released on the schedule page.
02/26: recorded lectures released
- The first part of the recorded lectures is released on Canvas.
02/25: Lab5 released
- Lab5 is released and will be due in two weeks (03/10/2025, 23:59).
02/23: Lecture Update for 02/24
- The instructor has the flu and is experiencing persistent coughing. As a result, the lecture on 02/24 will not be held in person. Instead, it will be recorded and made available online once the instructor has recovered. Thank you for your understanding.
02/11: Lab4 released
- Lab4 is released and will be due in two weeks (02/24/2025, 23:59).
01/30: Week5 office hour schedule change
- The coming office hour originally scheduled for Monday (02/03) is rescheduled to Tuesday (02/04) at 2PM.
01/28: Lab3 released and failed printing of mtime (Week4 lecture)
- Lab3 is released and will be due in two weeks (02/10/2025, 23:59).
Context
In Week4 lecture, we failed to print the mtime
value (8B) properly in C, with the helper function mtime_get()
. We got either 0
or some random numbers.
unsigned long long mtime_get() {
unsigned int low = *(unsigned int*)(CLINT0_MTIME);
unsigned int high = *(unsigned int*)(CLINT0_MTIME + 4);
return (((unsigned long long)high) << 32) | (unsigned long long)low;
}
What happened?
This issue is due to using an incorrect format specifier for printf
(or in the egos kernel, CRITICAL
). The return value of mtime_get()
is of type unsigned long long
(8B), but we used %d
(printing int
, 4B) and %lx
(printing long
in hex, 4B). When printf
meets a mismatch between format and type, its behavior is undefined, meaning the code can do literally anything.
Reproducing the problem
Want to reproduce this problem? Try the following code in grass.c:main():
unsigned long long a = mtime_get(); // use the above helper function
CRITICAL("%d (undefined behavior)", a); // we did this in Week4 lecture
CRITICAL("%lx (undefined behavior)", a); // we did this in Week4 lecture
CRITICAL("%lx", (unsigned long)a); // cast 8B to 4B
CRITICAL("%llx", a); // correct version
// print what has been stored on each byte
char *c = (char*)&a;
for (int i=0; i<8; i++) {
CRITICAL("[%d]: %x", i, c[i]);
}
01/18: no office hours on Monday (Martin Luther King Day)
- If you want to reach out, please use Piazza for public questions and mailing list for private questions.
01/14: Lab2 released
- Lab2 is released and will be due in two weeks (01/27/2025, 23:59).
01/12: office hours
- Please find our office hours on homepage
01/06: Lab1 released
- Lab1 is released and will be due in a week (01/13/2025, 23:59).
12/17: website created
Website created for spring 2025.