Vamshi
Vamshi

Reputation: 457

Does a process need a system call for accessing memory such as files, local memory on RAM?

Whenever we open a program and choose dialog box (say for libre office) for selecting a file, We are actually traversing the file structure of the hard disk. But is that a system call?. if it is, then isn't that too much switching back to user and kernel modes as you click each folder which will make user interactive processes slow.?

What about the local memory which is loaded for a process. Does it need system call for accessing that?

Upvotes: 2

Views: 1892

Answers (1)

Linuxios
Linuxios

Reputation: 35793

Accessing the file system is a system call.

Something you have to realize is that "slow" has multitude of meaning n computers depending on your level of abstraction. At the assembly level, you are dealing in single CPU cycles, which are infinitesimally short and quick on a human scale. At a C language scale, something like Ruby is incredibly slow. At a user scale, that same Ruby code executes in the same (to a human) unnoticable amount of time.

Switching between kernel and userspace is only "slow" at an assembly level. Your computer is probably switching between the two thousands and thousands of times every second. Any slowness you perceive in file system manipulations come from the latency of the hard drive itself, which operates on its own timescale.

Your own processes memory is always directly accessible to your code. System calls are only necessary to set up new areas of paging like new allocated memory, shared memory, mmaped files, and so on. A switch into kernel space is also triggered if any of your memory accesses trigger a page fault to allow the kernel to page in/move around/error the missing page.

Upvotes: 2

Related Questions