Skip to content

Instantly share code, notes, and snippets.

@phonyphonecall
Created September 15, 2014 16:24
Show Gist options
  • Save phonyphonecall/a2a3813df1797a26baa8 to your computer and use it in GitHub Desktop.
Save phonyphonecall/a2a3813df1797a26baa8 to your computer and use it in GitHub Desktop.
README for cs537 P1
#Scott Hendrickson
NetID: 9067627977
09/15/2014
## Birthday Paradox Details
For this program I simply worked through each part. First handling program arguments with getopt, then the file reading, the algorithm execution was done a bit messy, then finally creates the output file. Ussually I would segement the code into more descriptive functions but it seems I got lazy on this one.
The simplified algorithm does the following:
```
for each value in fileValues:
dynamicallly allocate array value * sizeof(int)
for each trial in 1000 trials:
generate value # of random birthdays and place in file
look for match in birthdays
save results probability of positiveTrials/numberOfTrials
cleanup memory
write to output file
```
## Addnum System Call Details
To add the system call the first thing i did was place a copy of xv6 into git. Then feeling much more comfortable to freely hack away I began grepping for getpid. Anywhere I found implementation parts for it, I added in the correspoding addnum code. Testing was straightforward as I just added a new test into the usertests found in /user. Implementing addnum itself was done inside sysproc.c. The addnum value is saved inside a static int contained within the function. It's value will be preserved due to the globa nature of static variables. The argument can be grabbed with a call to argint(), just like sys_sbrk does.
This assignment would be extremely hard to do without a good working knowledge of grep and linux com
mand line navigation. VIM is also a helpful to have in the toolkit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment