예제 #1
0
short MP_setup(INT32 frame, INT32 pid, INT32 logical_page, INT32 state) {
	short static            first_time = TRUE;

	if (first_time == TRUE) {
		MP_initialize();
		first_time = FALSE;
	}

	if (frame < 0 || frame >= PHYS_MEM_PGS) {
		printf("Frame value %d is not in the range 0 - %d in MP_setup\n",
			frame, PHYS_MEM_PGS - 1);
		return 1;
	}
	if (pid < 0 || pid > 9) {
		printf("Input PID %d not in range 0 - 9 in MP_setup.\n", pid);
		return 1;
	}
	if (logical_page < 0 || logical_page >= VIRTUAL_MEM_PAGES) {
		printf("Input logical page (%d) not in range 0 - %d in MP_setup.\n",
			logical_page, VIRTUAL_MEM_PAGES - 1);
		return 1;
	}
	if (state < 0 || state > 7) {
		printf("Input state %d not in range 0 - 7 in MP_setup\n", state);
		return 1;
	}
	if (logical_page > 0 || pid > 0 || state > 0) {   // Check there's data 2014
		MP_ft.entry[frame].contains_data = TRUE;
		MP_ft.entry[frame].logical_page = logical_page;
		MP_ft.entry[frame].pid = pid;
		MP_ft.entry[frame].state = state;
	}
	return 0;
}
예제 #2
0
void MP_print_line(void)
{
    INT32 index;
    INT32 temp;
    char output_line3[PHYS_MEM_PGS + 5];
    char output_line4[PHYS_MEM_PGS + 5];
    char output_line5[PHYS_MEM_PGS + 5];
    char output_line6[PHYS_MEM_PGS + 5];
    char output_line7[PHYS_MEM_PGS + 5];
    char output_line8[PHYS_MEM_PGS + 5];

    /*  Header Line */
    SP_do_output("\n                       PHYSICAL MEMORY STATE\n");
    /*      First Line      */
    SP_do_output("Frame 0000000000111111111122222222223333333333444444444455555555556666\n");
    /*  Second Line */
    SP_do_output("Frame 0123456789012345678901234567890123456789012345678901234567890123\n");
    /*  Third - Eighth Line  */
    strcpy(output_line3, "                                                                 \n");
    strcpy(output_line4, "                                                                 \n");
    strcpy(output_line5, "                                                                 \n");
    strcpy(output_line6, "                                                                 \n");
    strcpy(output_line7, "                                                                 \n");
    strcpy(output_line8, "                                                                 \n");

    for (index = 0; index < PHYS_MEM_PGS; index++)
    {
        if (MP_ft.entry[index].contains_data == TRUE)
        {
            output_line3[index] = (char) (MP_ft.entry[index].pid + 48);
            temp = MP_ft.entry[index].logical_page;
            output_line4[index] = (char) (temp / 1000) + 48;
            output_line5[index] = (char) ((temp / 100) % 10) + 48;
            output_line6[index] = (char) ((temp / 10) % 10) + 48;
            output_line7[index] = (char) ((temp) % 10) + 48;
            output_line8[index] = (char) MP_ft.entry[index].state + 48;
        }
    }
    SP_do_output("PID   ");
    SP_do_output(output_line3);
    SP_do_output("VPN   ");
    SP_do_output(output_line4);
    SP_do_output("VPN   ");
    SP_do_output(output_line5);
    SP_do_output("VPN   ");
    SP_do_output(output_line6);
    SP_do_output("VPN   ");
    SP_do_output(output_line7);
    SP_do_output("VMR   ");
    SP_do_output(output_line8);
    MP_initialize();
}