In the original Unix, segmentation was used and there were three segments, text, data, and stack. The text segment occupies the virtual address space from 0 to 8K, and contains the instructions to be executed of the program. This segment is write protected and can be shared by processes executing the same program. The data segments begins at the virtual address 8K, and can grow by the system call malloc. This segment is writable and non-sharable. The contents of the newly allocated data segment are initialized to zero. The stack segment begins at the highest virtual address and grows automatically towards the address 0. To keep track of a shared text segment, a text table is maintained in the secondary memory. When a shared text segment is executed for the first time, an entry for the segment is allocated. The entry contains the starting address in the main memory and the number of processes sharing the segment. When this number reduces to zero, the corresponding text segment is freed.
Swapping is used in the original Unix to make more physical memory space for the currently running process. Both user and system data segment occupy contiguous memory location to reduce swapping latency. To allocate primary and secondary memory, first-fit algorithm is used. As the segment grows, it may not fit in the current location and then it will be moved to a new location large enough to accommodate the segment. If there is no location to accommodate a process, the process will be swapped out. The criteria for selecting a process to be swapped in, is the secondary storage residence time. The process to be swapped out will be the process waiting for a slow event, or the one in the primary memory long time. There is also a slight penalty for the size of the process.
Paging was first introduced to Unix in 3BSD, and also implemented in Solaris 2 as demand paging. The page size of Solaris 2 is 4096. The page replacement algorithm here is taken from the section 7.5.2 of [5] and that of not Solaris 2 but Unix System V. The page daemon (PID 2) scans the page frames circularly. A page is put on the free list if it is unused for n consecutive passes. System V has two variables min and max. When the number of free frames goes below min, the page daemon is waken up and it keeps running to until more than max number of frames are freed. The frame replacement is global, i. e., when freeing a frame it does not take into account whose frame it is.
SPARC chip on which Solaris 2 runs has three-level paging tables. Associated with each process is the context number, which is the pointer to the context table. The entry in the context table points the base address of the first level page table, which is index by [31:24] bit of the virtual address. The second and the third page tables are indexed by [23:18] and [12:17] bit of the virtual address respectively. TLB is also provided for fast average access time.