📄 tsosaux.c
字号:
/************************************************************************The test module for the operating system interfaceAuxiliary executable run alongside tsos.exe to testprocess switching speed(c) 1995 Innobase OyCreated 9/27/1995 Heikki Tuuri*************************************************************************/#include "../os0thread.h"#include "../os0shm.h"#include "../os0proc.h"#include "ut0ut.h"/*********************************************************************Test for shared memory and process switching through yield. */void test2(void)/*=======*/{ os_shm_t shm; ulint tm, oldtm; ulint* pr_no; ulint count; ulint i; printf("-------------------------------------------\n"); printf("OS-TEST 2. Test of process switching through yield\n"); shm = os_shm_create(1000, "TSOS_SHM"); pr_no = os_shm_map(shm); count = 0; printf("Process 2 starts test!\n"); oldtm = ut_clock(); for (i = 0; i < 100000; i++) { if (*pr_no != 2) { count++; *pr_no = 2; } os_thread_yield(); } tm = ut_clock(); printf("Process 2 finishes test: %lu process switches noticed\n", count); printf("Wall clock time for test %lu milliseconds\n", tm - oldtm); os_shm_unmap(shm); os_shm_free(shm);}/************************************************************************Main test function. */void main(void) /*======*/{ ulint tm, oldtm; oldtm = ut_clock(); test2(); tm = ut_clock(); printf("Wall clock time for test %lu milliseconds\n", tm - oldtm); printf("TESTS COMPLETED SUCCESSFULLY!\n"); os_process_exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -