-
Notifications
You must be signed in to change notification settings - Fork 25
Time Implementation #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Verification Issue: The time utility mostly meets the requirements of the issue. It spawns the command, records the time, and prints all three categories. However, two things stand out that should be addressed before merge. Testing After reviewing, the program does run and print timing information as expected. The -p flag switches formatting, and normal usage works with different commands. But, long durations may overflow the current type, and the -p branch does not currently conform to POSIX output (it prints seconds modulo 60 instead of total seconds with two decimals). Code Walkthrough Great stuff y’all. Two quick things: 1)Duration type can overflow int: In user/time.c line 4: raw can exceed an int for longer runs. Also noticed that it treats this as milliseconds elsewhere. I'd suggest uint64_t raw_ms and do all math with uint64_t to avoid truncation. 2)POSIX -p format should show total seconds with two decimals: real 61.23s for 61.23 seconds. I had ChatGPT suggest an alternate printf you can reference here: (also in user/time.c) Hope this makes sense, reach out if you need further explanation! Formatting The code formatting is generally consistent and matches the style of other user-space utilities in the project. No major issues there. High Level Checks: [x]PR fully resolves the task/issue [x] Does the PR have tests? [x] Does the PR follow project code formatting standards? [x] Does the OS still compile and run? Is documentation included? Code Checks: [x] Does the code achieve its intended purpose? [] Were all edge cases considered? [x] Is the code organized and maintainable? [x]Does the code maintain the same level of performance? |
CODE REVIEW #1Checking to make sure the functionality delivered matches the original goals? Yes, when pulled and launched, the time function and ploop work as explained in the comment. Correcting any minor formatting or documentation issues In file time.c you use Proposing ways to refactor the code to improve readability, efficiency, or correctness Less of a suggestion but more question on the use of Suggested Constants: Possible Updates:
You should also verify each item in the following checklist: High Level Checks:
Code Checks:
|
|
This is excellent work and probably more than you expected since it required some kernel modifications. I appreciate the approach you took on tackling this and I like where it ended up (using wait to do this is also what Linux does). Since we don't have floating point math here, it's okay that you're just approximating the decimal places. Feedback wise:
Final score: 4.75 |
|
Forgot to mention: you are returning 1 on successful exit, but success should be = 0. |
Time
This branch aims to implement the Time program from the original Linux OS to FogOS. Time aims to measure the time it takes for other programs to run.
Usage:
time [program here] [other arguments]
Examples:
Flag
-p : Prints out the time in POSIX format
Output:
Explanation:
It should print out the real, user, and sys time in that order. Real time (real) is the total elapsed time that passed since running your program of choice. It includes bits of time that the CPU does not capture. User space time (user) is the total amount of time the CPU spends in the user space. Kernel space time (sys) is the total amount fo time the CPU spends in the kernel space.
Default:
real 0m0.000s
user 0m0.000s
sys 0m0.000s
POSIX (-p):
real 0.00
user 0.00
sys 0.00
Note:
Kernel Space Time + User Space Time does NOT equate to Real Time and, by extension, any equivalent algebraic expressions of that is also not true
Tests
So you're looking to code review this. Awesome. I need the help
You can start by doing basic commands like:
PLOOP
ploop.c is another utility that I added that just does a for loop.
Usage
ploop [number]
This argument sets the amount of times the program loops
To save you the trouble of a number too big, 1550000000 gives around 5 seconds. You can go ahead and tweak that number to your liking
In Conclusion
time ploop 1550000000 is the example usage case
Have fun!