COMP 3000 Lab 2 2011
Jump to navigation
Jump to search
Part B (on your own)
- Typically, what does a guest OS's hard disk look like to the host OS?
- Do guest OSs need the same device drivers as host OSs? Why?
- Why do we "open" files? Specifically, to what extent is it possible to do file I/O without open and close operations - assuming you could change the UNIX API?
- What is the relationship between dynamic library calls and system calls?
- What type of programs should run at near-native efficiency within a virtual machine? Why?
- What type of programs should be significantly slower within a virtual machine? Why?
- What are two strategies for accelerating programs that are slow within VMs?
- What are "guest additions" for VMs? What are they for?
/* perf.c for linux */ #include <stdio.h> #include <time.h> #define TIMEVARS() clock_t start, stop; double sec #define TIMESTART(msg) printf(msg "..."); fflush(stdout); start = clock() #define TIMESTOP() stop = clock(); \ sec = ((double)(stop-start))/CLOCKS_PER_SEC; \ printf("done (%.3f seconds)\n", sec) int main() { int n1 = 12345,n2 = 188765; int i= 0 ,j=0,composite = 0; TIMEVARS(); TIMESTART("Starting work"); for(i = n1; i < n2; i++) { for(j = 2; j < i; j++) { if (i%j == 0) { composite++; break; } } } TIMESTOP(); printf("%d primes found between %d and %d\n",n2-n1 - composite,n1,n2); return 0; }
/* perf.c for windows - compile using Visual Studio C++ compiler 2010 */ #include "stdafx.h" #include <cstdio> #include <ctime> #define TIMEVARS() clock_t start, stop; double sec #define TIMESTART(msg) printf(msg "..."); fflush(stdout); start = clock() #define TIMESTOP() stop = clock(); \ sec = ((double)(stop-start))/CLOCKS_PER_SEC; \ printf("done (%.3f seconds)\n", sec) int _tmain(int argc, _TCHAR* argv[]) { int n1 = 12345,n2 = 188765; int i= 0 ,j=0,composite = 0; TIMEVARS(); TIMESTART("Starting work"); for(i = n1; i < n2; i++) { for(j = 2; j < i; j++) { if (i%j == 0) { composite++; break; } } } TIMESTOP(); printf("%d primes found between %d and %d\n",n2-n1 - composite,n1,n2); return 0; }