Java is a managed language which offers memory safety.
In Java, pointers do not exist, so we cannot do pointer arithmetic on a function pointer. An application can invoke a method defined in a class through the class object. In Java, we cannot do unsafe typecast of an object to overwrite the method pointer with something else. An out of bound array access throws a runtime exception in Java, so return address corruption is not possible.
Now, let us look at some important aspects of an Operating System implemented through Java.
- Memory isolation:
In Java, memory can only be accessed via objects. A Java application cannot access memory outside an object. The virtual memory is not abstracted to the application. Due to these reasons, we do not need additional hardware support (segmentation/page tables) for process allocation. There is no need for page tables or privilege rings. The kernel is itself a Java process, so both kernel and untrusted applications execute in ring-0.
- System Calls:
To execute system calls, we need to switch to the kernel process. Switching to a different process does not require a page table switch. So, the system call handler is just a context switch routine that copies system call arguments in kernel address space and directly jumps to the system call handler.
- Inter Process Communication (IPC):
IPC is similar to the system call handler. The context switch method needs to invoke the receive routine in the target process after copying messages. So, this is better in comparison to Linux and Windows, where we have to do two ring transitions and one context switch to schedule the target routine.
- Device drivers:
Each device driver can be assigned to a separate Java process. Device drivers can talk to kernel via system calls.
But, the existing operating systems are not written in Java. It is because, Java is not an efficient language particularly due to garbage collection that can cause arbitrary latencies.
Therefore all the Operating Systems use C language extensively instead of Java.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Operating Systems | Set 1
- Operating Systems | Set 2
- Operating Systems | Set 3
- Operating Systems | Set 4
- Operating Systems | Set 5
- Operating Systems | Set 6
- Operating Systems | Set 10
- Operating Systems | Set 7
- Operating Systems | Set 8
- Operating Systems | Set 9
- Operating Systems | Set 11
- Operating Systems | Set 12
- Operating Systems | Set 13
- Operating Systems | Set 14
- Operating Systems | Set 15
- Operating Systems | Set 16
- Operating Systems | Set 17
- Producer-Consumer solution using threads in Java
- Convoy Effect in Operating Systems
- Commonly Asked Operating Systems Interview Questions | Set 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.