Results 1 to 8 of 8

Thread: HELP! Question about System calls when reading a HDD

  1. #1
    Who the $%£# told you you could eat my cookies?! Oobie-'s Avatar
    Join Date
    Aug 2005
    Posts
    1,299
    Thanks
    96
    Thanked
    17 times in 16 posts

    HELP! Question about System calls when reading a HDD

    Hey guys,

    Ive got a question to answer, but I'm slightly stumped about where to start and what to talk about, so I was wondering if you could help me.

    The question:

    Disk transfers are carried out using DMA and an interrupt is raised when the operation completes.
    Explain what happens in the Operating System between a user application making a system call to
    read sector 50 from disk and the data being returned to the user's buffer, indicating any process scheduling that occurs, change in processor state, use of memory buffers, etc.



    Thanks.
    Last edited by Oobie-; 24-04-2008 at 07:08 PM.
    ¯\_(ツ)_/¯

  2. #2
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: HELP! Question about System calls when reading a HDD

    Pick an easy question why not?

    Quickest and easiest way to learn is read fdisk's source code and the disk i/o syscalls & subsystems in the linux kernels sources, if you really want to know the nitty gritty.

    In laymans terms, the application operates at the block level using the kernels IOCTRL syscall, like read n blocks from block x on dev /dev/sdy, the kernel figures out what subsystem that block device uses from an internal struct table, instructs the driver to perform the required operation and blocks the app, the implementation from here varies from one i/o controller to another, but generically the CPU leaves instructions in ram, and sends an IRQ to the controller with a pointer to the memory location, the device reads the commands, executes them, passes even lower level (S)ATA commands to the HDD, which reads in the required data into the buffer, streams the data to the controller which in turn streams it into the ram buffer specified by the kernel, and sends an IRQ to the CPU that the commands were executed, or halted due to full a buffer, giving it time to read the memory in from ram into a separate buffer in userspace allocated by the app, then unblocks the app. E&OA
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  3. Received thanks from:

    Oobie- (24-04-2008)

  4. #3
    Who the $%£# told you you could eat my cookies?! Oobie-'s Avatar
    Join Date
    Aug 2005
    Posts
    1,299
    Thanks
    96
    Thanked
    17 times in 16 posts

    Re: HELP! Question about System calls when reading a HDD

    aha. Looks convincing!

    Just looking at each bit and trying to expand now. Thanks aidanjt.
    We're talking about how linux is handling this system call, as I'm assuming that windows may do it slightly differently?
    ¯\_(ツ)_/¯

  5. #4
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: HELP! Question about System calls when reading a HDD

    It may well do slightly, but I've never bothered to explore windows internal kernel stuff, it's much easier finding freely available documentation and source code for linux, so i'd stick with that for kernel/hardware interaction theory.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  6. #5
    Who the $%£# told you you could eat my cookies?! Oobie-'s Avatar
    Join Date
    Aug 2005
    Posts
    1,299
    Thanks
    96
    Thanked
    17 times in 16 posts

    Re: HELP! Question about System calls when reading a HDD

    ah ok cool.

    Is there a link handy that you could supply me that has fdisk's source code, please?
    ¯\_(ツ)_/¯

  7. #6
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: HELP! Question about System calls when reading a HDD

    Sure, it's part of the util-linux package, you can download it from: Index of /pub/linux/utils/util-linux-ng

    Obviously you can download the kernel sources from the same site if you browse backwards through the http server.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  8. #7
    Who the $%£# told you you could eat my cookies?! Oobie-'s Avatar
    Join Date
    Aug 2005
    Posts
    1,299
    Thanks
    96
    Thanked
    17 times in 16 posts

    Re: HELP! Question about System calls when reading a HDD

    Hmmmm, just as I suspected. Unfortunately my knowledge in C and C++ isn't strong enough to understand that source code, haha.

    So that code is executed by the kernal, and in it, is how system calls are handled?

    Could I confirm a few things from your original post -
    whats /dev/sdy
    when the cpu leaves instructions in the ram - do you mean it leaves the application instructions in the ram or something else?
    and
    the pointer to the memory location - thats the pointer to the said application for returning to it (if my above statement is correct?)

    Thanks
    Last edited by Oobie-; 26-04-2008 at 06:33 PM.
    ¯\_(ツ)_/¯

  9. #8
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: HELP! Question about System calls when reading a HDD

    Sorry, been working hard the last few days.

    The code is executed by the app, the apps syscalls trigger the running of code that already exists in the kernel, it's much the same as using the fopen() libc function for opening files, but at a lower kernel and hardware level interaction, it bypasses ordinary virtual filesystem cache, filesystem implimentation, and libc.

    In linux, nearly all hardware devices are represented by virtual files called device nodes, the location for SCSI (or SATA/Generic) disks are at /dev/sd? where '?' is a letter starting from a to z.

    Command passing in storage devices is a bit like leaving the plans for building something in a certain part of the building, then you send the storage device a simple message saying where you left the set of commands needed to complete the job. So basically, a pointer is just a variable that points to where another (set or single) variable is.

    Hope it helps clarify.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. System restore question
    By hovick in forum Software
    Replies: 3
    Last Post: 31-12-2007, 05:38 PM
  2. Abit NF7-S revision 2 information
    By Lee H in forum SCAN.care@HEXUS
    Replies: 22
    Last Post: 30-10-2004, 07:13 PM
  3. hdd question
    By edster in forum PC Hardware and Components
    Replies: 4
    Last Post: 22-04-2004, 01:21 AM
  4. Newbie needing help with Barton XP2500+ system...
    By adlamb in forum PC Hardware and Components
    Replies: 17
    Last Post: 12-04-2004, 05:05 PM
  5. system folders on second hdd
    By Gubs in forum Software
    Replies: 1
    Last Post: 14-08-2003, 02:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •