The RAM can be divided into two parts. The kernel space and user space. The kernel runs in the kernel space, which no other programs can access. User programs have to run in user space. User space is a form of sand-boxing, where user programs can only access to memory that allocated to them so that they can't mess up other programs and the kernel. To use the system resource, a program uses system calls to access a certain part of the kernel space and back to user space when the call return.
Kernel manages operating system resources. User program can only access to those resources by making system calls to the kernel. System call is similar to an API of kernel, which in term, runs kernel tasks your program needs.
str = "something" // run on user space x = x + 1 // run on user space file.write(str) // switch to kernel space y = x + 4 // switch back to user space
Use time command.
time ./perl-timeout-example 100.100.100 We could not ping the desired address! real 0m5.0013s user 0m0.004s sys 0m0.008s
Normally, user + sys is the total CPU time spent on such process. It is smaller than real. But in multicore CPU, user + sys is the total CPU time spent on this process. It could be large than real.