• Post Reply Bookmark Topic Watch Topic
  • New Topic

System calls?  RSS feed

 
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hey guys so Java like any other programming language is translated into machine code obviously,and system calls are the interface between the hardware and the OS itself,how does the operating System deal with the code like in the above example,does Java actually make system calls and what is the difference between a system call and lets say System.out.println in the example,are any of the lines above making a system call?

I have not found much on this topic apart from one link but it's mainly focused on C,sorry about all the questions just very curious.
 
author & internet detective
Marshal
Posts: 37518
554
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam,
Good question. Java compiles into bytecode and the JVM knows how to run the bytecode. So at a low level, writing to the console is something the JVM knows how to do. (Which means calling low level system code at some point).
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanee =) yeah I forgot to post about the JVM which convers the code into bytecode which then turns it into the native machine code
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Chalkley wrote:. . . the JVM which convers the code into bytecode which then turns it into the native machine code
That is a low‑level implementation detail which you don't need to know about. And how do you know the JVM converts the bytecode into machine code? I hope you haven't read that anywhere, but if you have, please tell us where, so we know to avoid that source as mistaken. Much of the time the JVM looks on the bytecode as direct instructions and those are interpreted directly  by the JVM without being turned into machine code. That is why if you search for “Java buzzwords” some of the results will say it is interpreted, for example the white paper by Gosling and McGilton when Java® first came out. I don't know why the recent versions of the Java™ Tutorials omit “interpreted”, but that link is worth reading. It also tells you whether bytecode is turned into machine code.

Careful about spellings of names. Don't declare several variables on the same line. Add some spaces; one space after each comma would make your line 5 much easier to read. That code won't compile because you didn't supply an initial value for result before trying to print it.
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell =)
 
Ranch Hand
Posts: 4696
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a low‑level implementation detail which you don't need to know about.

most of the time, i agree. i once had to make a system call to windows for it to increase the priority of my real-time program. i wrote it in VB and finally got help at a VB website. i had to make a system call to increase the priority of my program(it was dropping characters occasionally).
 
Ranch Hand
Posts: 231
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And how do you know the JVM converts the bytecode into machine code?

The link you provided does say that in order to boost performance, some JVMs do recompile frequently used sections of bytecode to native code (machine code).
 
Randall Twede
Ranch Hand
Posts: 4696
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why wouldn't they if they could?
i dont really know, but i think a system call in java looks just like in VB.
the calls to OpenGL look similar.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Cox wrote:. . . in order to boost performance, some JVMs do recompile frequently used sections of bytecode to native code (machine code).
Did you know that before I showed you the link? The norm is to interpret bytecode directly and only sections which the JVM perceives as performance bottlenecks are recompiled into machine code. If you search for Java and Just In Time Compilation, you may find out more about it. Note the abbreviation JiT or JIT.
 
Daniel Cox
Ranch Hand
Posts: 231
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough. The HotSpot JVM doesn't do the recompiling itself; while executing bytecode, it analyzes it for hot spots (frequently used sections) and uses its just-in-time (JIT) compiler to optimize these hot spots in order to boost performance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!