Thread: Programming and RAM

  1. #1
    Registered User
    Join Date
    Jun 2005

    Programming and RAM

    Hi all,

    I am working to find an implementation strategy(in C for some application) for an embedded system with 24KB RAM.

    I am trying to understand how the execution of code written in C is dependent on the size of RAM.

    I understand that the whole source code will not reside in RAM.
    Only part of data which the processor needs immediately will be loaded into RAM.

    Which parts of the code actually reside in RAM?

    or How much RAM is needed for a source code to execute?

    In what way can I keep the contraint of 24KB RAM in mind, while I write my program in C?

    Can you please tell how I should think about this?
    I am actually confused.

    Hope someone can make my mind clear about this.

    Thank you

  2. #2
    Registered User
    Join Date
    Apr 2005
    I am no expert on embedded systems, but could you elaborate what kind of code you are planning to load in RAM. Is it some application or some kernel module.? What OS you are you working on. ?

    If the module is a kernel module, one way to reduce the code size is to include minimum header files in your code. Use already exported symbols (variables, functions) by the kernel or OS or share them among multiple soruce files. Your linker should take care of linking them in final build process.

    Check the OS documentation for your emebedded system to find out the APIs.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    The actual code size will be dependent on which opcodes/instructions the compiler generates when it turns your C code into machine language.

    There is no real way to determine the size of your code until you compile it. As for arrays and such and assuming you know the data alignment being used, it is normally arraylength*sizeof(data_type_of_array).

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > or How much RAM is needed for a source code to execute?
    Depends how much you expect to get done.
    A simple for loop for example probably occupies only a few bytes.

    > I understand that the whole source code will not reside in RAM.
    So some of the code is where else? Flash memory?

    My initial thought is that the following fits into 24K
    - the segment loader to load segments when they're needed
    - some kind of function index to help the segment loader find the code you need next
    - your run-time data
    - the most common functions (so you're not continually swapping)
    - some free space for swapping in segments on demand.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers basics (C and other Programming Lamguages)
    By neilsequeira in forum C Programming
    Replies: 5
    Last Post: 08-19-2007, 03:21 PM
  2. Programming a PIC 16F84 microcontroller in C
    By Iahim in forum C Programming
    Replies: 1
    Last Post: 05-13-2004, 02:23 PM
  3. What causes bad ram?
    By daveS in forum Tech Board
    Replies: 10
    Last Post: 09-03-2003, 07:06 PM
  4. C Programming
    By gaurav in forum C Programming
    Replies: 0
    Last Post: 02-17-2002, 09:19 AM
  5. graphics programming idea
    By iain in forum A Brief History of
    Replies: 5
    Last Post: 01-18-2002, 08:41 AM