Programming and RAM

This is a discussion on Programming and RAM within the C Programming forums, part of the General Programming Boards category; Hi all, I am working to find an implementation strategy(in C for some application) for an embedded system with 24KB ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    13

    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
    Posts
    134
    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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 08:19 AM
  5. graphics programming idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 01-18-2002, 07:41 AM

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