Expert C Programming

(Jeff_L) #1

You can also try adjusting the segment limits in C-shell:


limit stacksize 10


You can adjust the maximum size of the stack and the data segments in the C-shell. The line
above sets it to 10 Kbytes. Try giving your program less stack space, and see if it fails at an
earlier point. Try giving it more stack space, and see if it now runs successfully. A process
will still be limited overall by the size of swap space, which can be found by typing the
swap -s command.


Anything can happen with a bad pointer value. The accepted wisdom is that if you're "lucky," it will
point outside your address space, so the first use will cause the program to dump core and stop. If
you're "unlucky," it will point inside your address space and cor-rupt (overwrite) whatever area of
memory it points at. This leads to obscure bugs that are very hard to track down. A number of
excellent software tools have come on the market in recent years to aid in solving this kind of problem.


Some Light Relief—The Thing King and the Paging Game


The section that follows was written by Jeff Berryman in 1972 when he was working on project MAC
and running one of the early virtual memory systems. Jeff somewhat rue-fully comments that of all the
papers he has ever written, this one is the most popular and widely read. It's as applicable today as it
was twenty years ago.


The Paging Game


This note is a formal non-working paper of the Project MAC Computer Systems Research Division. It
should be reproduced and distributed wherever levity is lacking, and may be referenced at your own
risk in other publications.


Rules



  1. Each player gets several million things.

  2. Things are kept in crates that hold 4096 things each. Things in the same crate are
    called crate-mates.

  3. Crates are stored either in the workshop or the warehouse. The workshop is almost
    always too small to hold all the crates.

  4. There is only one workshop but there may be several warehouses. Everybody shares
    them.

  5. Each thing has its own thing number.

  6. What you do with a thing is to zark it. Everybody takes turns zarking.

  7. You can only zark your things, not anybody else's.

  8. Things can only be zarked when they are in the workshop.

  9. Only the Thing King knows whether a thing is in the workshop or in a warehouse.

  10. The longer a thing goes without being zarked, the grubbier it is said to become.

  11. The way you get things is to ask the Thing King. He only gives out things in multiples
    of eight. This is to keep the royal overhead down.

Free download pdf