Skip to main content Link Menu Expand (external link) Document Search Copy Copied

User limits

Now that you have dusted off your C skills and gained some familiarity with the CS 162 tools, we want you to understand what is really inside of a running program and what the operating system needs to deal with. The operating system needs to deal with the size of the dynamically allocated segments: the stack and heap. How large should these be? Poke around a bit to find out how to get and set these limits on Linux. Modify limits.c so that it prints out the maximum stack size, the maximum number of processes, and maximum number of file descriptors. Currently, when you compile and run limits.c you will see it print out a bunch of system resource limits (stack size, heap size, etc.). Unfortunately all the values will be 0. Your job is to get this to print the ACTUAL limits (use the soft limits, not the hard limits). Hint: run man getrlimit

You should expect output similar to this:

stack size: 8000000
process limit: 30000
max file descriptors: 1000

You can run make limits to compile your code.