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

  • SEARCH
  • Home
  • 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 6354917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:39:41+00:00 2026-05-24T22:39:41+00:00

To extend the title.I am wondering how the OS handles functions like fwrite,fread,fopen and

  • 0

To extend the title.I am wondering how the OS handles functions like fwrite,fread,fopen and fclose.

What is actually a stream?

Sorry if I was not clear enough.

BTW I am using GNU/Linux Ubuntu 11.04.

A bit better explanation of what I am trying to ask.

I want to know how are files written to HDD how are read into memory and how can is later a handle to them created.Is BIOS doing that through drivers?

  • 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-05-24T22:39:44+00:00Added an answer on May 24, 2026 at 10:39 pm

    The C library takes a function like fopen and converts that to the proper OS system call. On Linux that is the POSIX open function. You can see the definition for this in a Linux terminal with man 2 open. On Windows the call would be CreateFile which you can see in the MSDN documentation. On Windows NT, that function is in turn another translation of the actual NT kernel function NtCreateFile.

    A stream in the C library is a collection of information stored in a FILE struct. This is usually a ‘handle’ to the operating system’s idea of the file, an area of memory allocated as a ‘buffer’, and the current read and write positions.

    I just noticed you tagged this with ‘assembly’. You might then want to know about the really low level details. This seems like a good article.

    Now you’ve changed the question to ask about even lower levels. Well, once the operating system gets a command to open a file, it passes that command to the VFS (Virtual File System). That piece of the operating system looks up the file name, including any directories needed and does the necessary access checks. If this is in RAM cache then no disk access is needed. If not, the VFS sends a read request to the specific file system which is probably EXT4. Then the EXT4 file system driver will determine in what disk block that directory is located in. It will then send a read command to the disk device driver.

    Assuming that the disk driver is AHCI, it will convert a request to read a block into a series of register writes that will set up a DMA (Direct Memory Access) request. This looks like a good source for some details.

    At that point the AHCI controller on the motherboard takes over. It will communicate with the hard disk controller to cooperate in reading the data and writing into the DMA memory location.

    While this is going on the operating system puts the process on hold so it can continue with other work. The hardware is taking care of things and the CPU isn’t required to pay attention. The disk request will take many milliseconds during which the CPU can run millions of instructions.

    When the request is complete the AHCI controller will send an interrupt. One of the system CPUs will receive the interrupt, look in its IDT (Interrupt Descriptor Table) and jump to the machine code at that location: the interrupt handler.

    The operating system interrupt handler will read some data, find out that it has been interrupted by the AHCI controller, then it will jump into the AHCI driver code. The AHCI driver will read the registers on the controller, determine that the read is complete, put a marker into its operations queue, tell the OS scheduler that it needs to run, then return. Nothing else happens at this point.

    The operating system will note that it needs to run the AHCI driver’s queue. When it decides to do that (it might have a real-time task running or it might be reading networking packets at the moment) it will then go read the data from the memory block marked for DMA and copy that data to the EXT4 file system driver. That EXT4 driver will then return the data to the VFS which will put it into cache. The VFS will return an operating system file handle to the open system call, which will return that to the fopen library call, which will put that into the FILE struct and return a pointer to that to the program.

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

Sidebar

Related Questions

I have SELECT * FROM hnurl WHERE title LIKE('%text1%') How do I extend this
I notice when I have code like: http://jsfiddle.net/MtULf/1/ window.Todo = Backbone.Model.extend({ defaults: { title:
My model looks like the following right now: window.List = Backbone.Model.extend({ title: null, idAttribute
The code: var Appointment = Backbone.Model.extend({}); var appointment = new Appointment(); appointment.set('title', 'My knee
To extend RavenDB's capabilities I would like to install the bundles that are available
I have two different models in my application App.Foo = DS.Model.extend({ title: DS.attr('string') });
Title covers it all. I'd like classes which implement IDisposable to show up in
I'm trying to extend a class like panel so that I can fire click
I have a collection of Backbone models like so: window.Message = Backbone.Model.extend({}); window.MessageCollect =
var App = Em.Application.create(); App.store = DS.Store.create({ adapter: DS.RESTAdapter.create() }); App.Todo = DS.Model.extend({ title:

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.