Difference between ROM and RAM..

This is a discussion on Difference between ROM and RAM.. within the C Programming forums, part of the General Programming Boards category; Dear All, As per as my knowledge difference between ROM and RAM is that:- ROM:- Read Only memory..all I/O related ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    Difference between ROM and RAM..

    Dear All,
    As per as my knowledge difference between ROM and RAM is that:-

    ROM:- Read Only memory..all I/O related files will be stored and operating system files are stored...which can't be modified

    RAM:- Random access memory...data which can be repeatedly access by processor stored in this memory..

    Where is my final Executable C code will be stored?
    if your answer is RAM...RAM is volatile memory(Once power is off then data gets lost)...i am getting some kind of confuse can anybody clerify my question?

    Thanks in Advance

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Your executable is in RAM while it's running, certainly. But that's memory; that's not storage. All that stuff on your disk is just that: on disk.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    ROM is not used too much in your computer. Most likely, the only ROM it has is for the BIOS, when the computer first starts up. Almost everything is stored on the hard drive, because the hard drive retains its information even when the power to it is cut out, unlike RAM, of course.

    The nice thing about RAM is that it's so fast. RAM is used by currently running programs.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,455
    Depends on how you see it. RAM is slow compared to the CPU, and the HDD is slow compared to the RAM.
    Lots of bottlenecks in today's systems, the biggest one being the HDD which will improve in the future.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Quote Originally Posted by Elysia View Post
    Depends on how you see it. RAM is slow compared to the CPU
    Yeah, but do you think that most CPUs have enough registers to store all of the data required to run Vista?

    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,455
    Today's processors have a direct bus to the memory nowadays. What's required now is faster RAM. It's too slow compared to the CPU.
    Then you don't need to worry so much about enough registers to run Vista.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Mm'kay. What I meant was that RAM is fast compared to hard drives.

    Run lots of programs, get a big swapfile, and you'll see what I mean . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    When you get down to it there are several layers of memory, each about an order of magnitude slower to access then the next. The fastest is the L1 CPU cache. Then L2 CPU cache. Then RAM. Then the hard disk virtual memory.

    But yeah, your program is loaded off the hard disk and stored in RAM before it is run. Some CPUs will have a separate code bus that speeds up the execution of code by separating it from the data, but still the same RAM is used for both data and (machine) code. Both can be cached or visualized as needed.

    For embedded chips programmable ROM is often used instead of a hard disk to store the code as well as any initial data needed to run.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    Difference between RAM and ROM

    Quote Originally Posted by tabstop View Post
    Your executable is in RAM while it's running, certainly. But that's memory; that's not storage. All that stuff on your disk is just that: on disk.
    Hai,
    you told my executable code will be in RAM..but once power is off it gets erase know..do have any back up for this..do you know any good site in google to read this memory operations clearly...

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,455
    Look, it's easy.
    Data is permanently stored on the HDD. The HDD keeps its data even when the computer is powered off.
    Your OS loads your program into memory when you run it. Then it's removed or discarded from memory once finished running.
    There's nothing else to it. You shut down your computer, you start it up, the process repeats.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You have a source file, program.c. It is sitting on your hard drive. It is safe; turn off your computer, and it will remain on the disk.

    You compile this program into program.exe. This file, too, is on your hard drive. It will not be deleted because you turned off your computer.

    When you run program.exe, that instance of the program is in RAM. This instance will be lost if you shut down your computer.

    But it's nothing to worry about, really. Your source code and the compiled .exe are just files on your computer. You know how files work. You can copy them, move them around, and delete them. But they don't generally delete themselves every time you reboot your computer.

    Yes, the instance of program.exe will be lost if you shut down your computer. But so will Microsoft Word, if you happened to have that running. Any programs in memory, i.e. in RAM, any running programs at all, will be terminated if you turn off your computer! It's nothing to worry about, because you can always run them again.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #12
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    Quote Originally Posted by shwetha_siddu View Post
    Hai,
    you told my executable code will be in RAM..but once power is off it gets erase know.
    Yes, exactly. So if you were to suddenly turn the power off, you would loose whatever you were working on. Unless the program periodically auto-saves, which many programs do.

    It's nothing to worry about, because you can always run them again.
    Sure, if you don't mind rewriting that 10 page paper from scratch. (Just emphasizing a point)
    Last edited by King Mir; 06-22-2008 at 10:53 PM.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    83

    Thanks for useful information...

    Quote Originally Posted by dwks View Post
    You have a source file, program.c. It is sitting on your hard drive. It is safe; turn off your computer, and it will remain on the disk.

    You compile this program into program.exe. This file, too, is on your hard drive. It will not be deleted because you turned off your computer.

    When you run program.exe, that instance of the program is in RAM. This instance will be lost if you shut down your computer.

    But it's nothing to worry about, really. Your source code and the compiled .exe are just files on your computer. You know how files work. You can copy them, move them around, and delete them. But they don't generally delete themselves every time you reboot your computer.

    Yes, the instance of program.exe will be lost if you shut down your computer. But so will Microsoft Word, if you happened to have that running. Any programs in memory, i.e. in RAM, any running programs at all, will be terminated if you turn off your computer! It's nothing to worry about, because you can always run them again.

    But i am getting confuse with :-
    1. what is difference between data and code?
    2. Running and compiling?
    3. What is Role of ROM? i heard that some instance we will transfer data from EEPROM to RAM to ROM what for this?

  14. #14
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    ROM is used to get the computer operational when it powers on. It basically tells the computer how to find out what it has and what to do.

    Your program will not be utilizing ROM unless your are writing a super low level program to load the ROM with new data.


    Compiling is basically the act of taking your code (the stuff you write) and translating it from a human readable format to a machine readable format.


    Code is basically instructions to the CPU. Data is the stuff it does those instructions onto. So a variable is data as is a text file. Code can also be treated as data but in practice that is rarely done on purpose.

  15. #15
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    Quote Originally Posted by shwetha_siddu View Post
    But i am getting confuse with :-
    1. what is difference between data and code?
    Not much. they are both ultimately numbers. Ones and zeros as they say. But code is treated spatially by the CPU. The code is read as a series of instructions that tell the computer how to manipulate data and what code to run next.

    2. Running and compiling?
    Ultimately, computers can only understand one language: machine code. But machine code is hard to write, so instead we use high level languages like C. A compiler is used to "compiler" or translate C into machine code.

    Running is actually telling the computer to execute a set of instructions that are written in a file. Typically this code is machine code, but it can also be script or bytecode, which has to be interpreted into machine by an interpreter. C is almost always compiled into machine code. exe files contain machine code.

    3. What is Role of ROM? i heard that some instance we will transfer data from EEPROM to RAM to ROM what for this?
    ROM is for embedded programing where there is no harddisk, and for BIOS that boots the OS from the hard disk initially. EEPROM is a type of programmable ROM -- ROM that has a special setting that allows it to be written to. This makes it possible to do things like update your BIOS.
    Last edited by King Mir; 06-22-2008 at 11:22 PM.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do this
    By BEN10 in forum C Programming
    Replies: 32
    Last Post: 05-28-2009, 02:22 AM
  2. Problem with the linker file
    By ssharish2005 in forum Tech Board
    Replies: 2
    Last Post: 04-24-2007, 05:46 AM
  3. pointer in rom
    By ramdal in forum C Programming
    Replies: 4
    Last Post: 12-19-2005, 08:33 AM
  4. less use of ram
    By ramdal in forum C Programming
    Replies: 4
    Last Post: 12-19-2005, 07:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21