5
votes

I want to have clarity on user space program and OS interaction. In the context of a file I/O, I want to know how a user app like a java file i/o API read() may work. Since file operations are accessed by POSIX system calls like open() close() read() write(), how does the java code calls these system calls ?

When we compile the java code, what kind of instructions the java read() API would be compiled to ? Its said, user programs raise traps/software interrupts to make system calls. So does Java read() API is also raise traps ? Are there APIs in java to Raise traps ? If yes, so those APIs might be compiled to trap instructions like 'INT' ? But then does INT calls higher layer POSIX system calls or some fixed ISRs (Interrupt Service Routines) ?

I am confused and trying to know step by step... from compilation to execution- how system calls are done in this scenario.

Please help me with this simple concept.

1
See JNI and JNA.user2864740
How JNI initiates calls to C/C++ libraries/programs ?sapthrishi007

1 Answers

0
votes

Perhaps I got a very good clarification on http://pages.cs.wisc.edu/~remzi/OSFEP/intro-syscall.pdf
Hence I enfer the following flow: Java Code -> JNI -> read() syscall in C -> kernel subroutines. But last doubt: How JNI which is in Java, calls C codes ?