Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:44:57+00:00 2026-06-12T13:44:57+00:00

When a program is compiled it is converted to machine code which can be

  • 0

When a program is compiled it is converted to machine code which can be “understood” by the machine. How does this machine code interact with the operating system in order to do things like getting input from the keyboard ?
To me, it seems that the machine code should run at a lower level than the operating system and therefore, I can’t understand how the OS can act as an intermediary between the compiled application and the hardware.

PS : I just started C ++ programming and I am trying to understand how cin and cout work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:44:59+00:00Added an answer on June 12, 2026 at 1:44 pm

    This is a very good question (better than you know), and there is a lot to learn. A LOT.

    I’ll try to keep it short. The operating system acts as a level of abstraction between software and hardware:

       Software
           .
          /|\    
           |   communicates with
          \|/
           '
    Operating System
           .
          /|\    
           |   communicates with
          \|/
           '
       Hardware
    

    The OS communicates with the hardware through programs called drivers (widely used term), and the OS communicates with software through procedures called system calls (not-so-widely used term).

    Essentially, when you make a system call, you are leaving your program and entering code of the operating system. System calls are the only way programmers are allowed to communicate with resources.


    Now I would stop there, but you also said:

    To me, it seems that the machine code should run at a lower level than
    the operating system and therefore, I can’t understand how the OS can
    act as an intermediary between the compiled application and the
    hardware.

    This is tricky, but simple once you understand some basics.

    First, all code is just machine code running on the CPU. No code is higher or lower than other code (with the exception of some commands that can only be run in a privileged kernel mode). So the question is, how can the OS possibly be in control even though it is relinquishing control of the CPU to the user?

    When code is running on a CPU, there is a concept called an interrupt. This is a signal sent to the CPU that causes the currently running code to stop and get switched out with another piece of code, called an interrupt handler.

    Examples of interrupts include the keyboard, the mouse, and most importantly, the clock.

    The clock interrupt is raised on a regular basis causes the operating system’s clock interrupt handler to run. Within this clock interrupt handler is the operating system’s code that examines what code is currently running determines what code needs to run next. This can be either more operating system code or more user code.

    Because the clock is always ticking, and because the operating system always gets this periodic chance to run on the CPU, it is able to orchestrate everything within the computer, even though it runs using the same set of CPU commands as any normal program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this code but I can't find out what is
'??' gets converted into '^' if I compile mn VC++ program and run it
The first program compiled properly.second gave error saying too few argument for foo... is
We're working on a C program compiled with arm-eabi-gcc under Linux. We're using a
Is there any way, from within a Java program compiled by gcj, to find
I am trying to test whether a c program has compiled and executed correctly
HI, I would like to run a cygwin compiled program in visual studio using
I'm new to Mono and just started recently. Is mono program are compiled from
I have a very basic program in C++ compiled in VS 11 Beta on
I need to get the global symbols from a compiled c program file. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.