|
|
1.1 ! root 1: static char ID[] = "@(#) house.c: 1.1 3/16/82"; ! 2: #include <stdio.h> ! 3: #include "sdp.h" ! 4: #include "define3.h" ! 5: ! 6: #ifdef SHORT ! 7: #define HO01 "HO01 " ! 8: #define HO02 "HO02 " ! 9: #define HO03 "HO03 " ! 10: #define HO04 "HO04 " ! 11: #define HOAU "HOAU " ! 12: #else ! 13: #define HO01 "HO01 -- illegal value of first parameter\n%d\n",num_frames ! 14: #define HO02 "%s","HO02 -- fail to allocate environment\n" ! 15: #define HO03 "%s","HO03 -- fail to allocate managers\n" ! 16: #define HO04 "HO04 -- fail to allocate frame\n%d\n",i ! 17: #define HOAU "%s","HOAU -- audit failed in sdp_house\n" ! 18: #endif ! 19: ! 20: #ifdef SWEET ! 21: #define PROLOG ! 22: #define EPILOG ! 23: #else ! 24: #define PROLOG if( (aud_flag == AUDITON) && (aud_check() == ERROR) )\ ! 25: ERR_RET(HOAU,NULL) ! 26: #define EPILOG if(aud_flag == AUDITON)\ ! 27: aud_set() ;\ ! 28: if(hist_fp != NULL)\ ! 29: fprintf(hist_fp,"HO\t%d\t%u\t%o\t%o\n",num_frames,frame_size,library,environ) ; ! 30: #endif ! 31: ! 32: extern int aud_flag ; ! 33: extern struct ENVIRON *first_environ ; ! 34: extern struct LIBFILE *Glib_file ; ! 35: extern struct LIBMEM *Glib_mem ; ! 36: extern FILE *hist_fp ; ! 37: extern struct LIBMEM lib_mem ; ! 38: ! 39: extern int *ALLOC() ; ! 40: extern int aud_check() ; ! 41: extern aud_set() ; ! 42: extern FATAL() ; ! 43: ! 44: struct ENVIRON * /* pointer to environment or NULL */ ! 45: sdp_house(num_frames,frame_size,library) ! 46: int num_frames ; ! 47: unsigned frame_size ; ! 48: struct LIBMEM *library ; ! 49: { ! 50: register struct ENVIRON *environ ; ! 51: register struct MANAGER *manager ; ! 52: register int i ; ! 53: ! 54: PROLOG ! 55: Glib_mem = (library == NULL) ? &lib_mem : library ; ! 56: ! 57: if(num_frames <= 0) ! 58: ERR_RET(HO01,NULL) ! 59: ! 60: if( (environ = (struct ENVIRON *)MALLOC(sizeof(struct ENVIRON))) == NULL ) ! 61: ERR_RET(HO02,NULL) ! 62: ! 63: environ->num_frames = num_frames ; ! 64: environ->frame_size = frame_size ; ! 65: environ->cnct_count = 0 ; ! 66: environ->lib_mem = Glib_mem ; ! 67: ! 68: if( (environ->manp = (struct MANAGER *)MALLOC((num_frames+1)*sizeof(struct MANAGER))) == NULL ) ! 69: ERR_RET(HO03,NULL) ! 70: ! 71: manager = environ->manp ; ! 72: environ->empties = 0 ; ! 73: for(i=0; i<num_frames; i++) ! 74: { ! 75: manager[i].space = NULL ; ! 76: manager[i].page_id = IDNULL ; ! 77: manager[i].forward = i+1 ; ! 78: manager[i].backward = END ; ! 79: manager[i].ref_chng = RCNULL ; ! 80: manager[i].usecount = 0l ; ! 81: if( (manager[i].frame_pntr = (char *)MALLOC(frame_size)) == NULL ) ! 82: ERR_RET(HO04,NULL) ! 83: } ! 84: ! 85: manager[num_frames-1].forward = END ; ! 86: manager[num_frames].forward = manager[num_frames].backward = num_frames ; ! 87: manager[num_frames].space = NULL ; ! 88: manager[num_frames].page_id = IDNULL ; ! 89: manager[num_frames].ref_chng = RCNULL ; ! 90: manager[num_frames].usecount = 0l ; ! 91: manager[num_frames].frame_pntr = NULL ; ! 92: ! 93: environ->stats.uses = 0l ; ! 94: environ->stats.faults = 0l ; ! 95: environ->stats.writes = 0l ; ! 96: environ->stats.maxuse = 0 ; ! 97: environ->stats.curuse = 0 ; ! 98: ! 99: environ->next_environ = first_environ ; ! 100: first_environ = environ ; ! 101: EPILOG ! 102: return(environ) ; ! 103: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.