• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System calls?

 
Ranch Hand
Posts: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 545
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell =)
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 234
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 234
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic