Usertimevs Systemtime-example2 What is the difference of the two programs?#define MAX1000000#define MAx 1000000int main(void)(int main(void)(int i;int i;for(i=o;i<MAX;i++)for(i=;i<MAX/5;i++)printf("x\n");printf(x|nxnx|nx|nx/n")return e;return ;子子Lessons learned: When writing a program, you mustconsider both the user time and the system time16
User time VS System time – example 2 • What is the difference of the two programs? 16 #define MAX 1000000 int main(void) { int i; for(i = 0; i < MAX; i++) printf(“x\n”); return 0; } #define MAX 1000000 int main(void) { int i; for(i = 0; i < MAX / 5 ; i++) printf(“x\nx\nx\nx\nx\n”); return 0; } Lessons learned: When writing a program, you must consider both the user time and the system time
User time vs System time-short summary? The user time and the system time together definethe performance of an application-System call playsa majorroleinperformanceBlocking system call: some system calls even stop yourprocess until the data is available. Programmers should pay attention to systemperformance- Reading a file byte-by-byte Reading a file block-by-block, where the size of a block is4,096 bytes17
User time VS System time – short summary • The user time and the system time together define the performance of an application – System call plays a major role in performance. – Blocking system call: some system calls even stop your process until the data is available. • Programmers should pay attention to system performance – Reading a file byte-by-byte – Reading a file block-by-block, where the size of a block is 4,096 bytes 17
Story so far..User space and Kernel spaceUser time and system time三Process18
18 Story so far. User space and Kernel space Process Process User time and system time
Next...Working of system calls- fork();exec*();wait() + exit();巨Process19
19 Next. Working of system calls - fork(); - exec*(); - wait() + exit(); Process Process
Next...Working of system calls- fork();exec*();wait() + exit();巨Process20
20 Next. Working of system calls - fork(); - exec*(); - wait() + exit(); Process Process