Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a file read from a Java application invoke a system call?

My understanding is that a user application requesting a file system path (eg. /aFile) will invoke the File System and get back the virtual address of the requested file. Then the application will attempt a read/write operation with that address as argument, that as a CPU instruction? On execution of the read command the Memory Management Unit will translate that address into the phisical address, looking into a page table. In case the user has not privilege to access that memory location (where is that information carried?) the operation is aborted. Otherwise, if the physical address page is found in memory, the read/write operation is carried on it, otherwise the page is brought in from disk and the operation is repeated.

So, there seems to be no system call at all. Could someone correct possible mistakes in the above procedure detail?

like image 719
simpatico Avatar asked Jul 03 '10 13:07

simpatico


People also ask

What invokes the system calls?

When a user program invokes a system call, a system call instruction is executed, which causes the processor to begin executing the system call handler in the kernel protection domain. This system call handler performs the following actions: Sets the ut_error field in the uthread structure to 0.

Can Java make system calls?

When can we make System calls? From a Java application we can make system calls in such situations as to copy a file/shortcut from one location to another, delete a file, to hide a folder to save it from accidental delete, to run a shortcut file or launch another application from java during run time etc.

What is read () system call?

The read system call interface is standardized by the POSIX specification. Data from a file is read by calling the read function: ssize_t read(int fd, void *buf, size_t count); The value returned is the number of bytes read (zero indicates end of file) and the file position is advanced by this number.

What is a system call Java?

System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system.


1 Answers

(typically) when you open/read/write a file in Java, a call is made to the OS kernel , aka. a system call,for opening/read/write that file. How that is done and the memory management involved is entierly in the hands of the kernel, but eventually bytes read from the file is copied back to a buffer supplied through the system call.

like image 106
nos Avatar answered Nov 15 '22 00:11

nos