cyclegugl.blogg.se

Memory note
Memory note










memory note
  1. #Memory note how to#
  2. #Memory note code#

Note here that a page can be allocated,īut not currently in the physical memory. With the operating system, which says "I haven'tĪllocated the page containing location zero for you". When you say " c = *s", the hardware sees that you To get segmentation violation, and this is only one of them). Not, you'll get a segmentation violation (note, there are many ways If so, then it goes ahead and performs the read/write. System to see if that address belongs to a page that has been allocatedįor you. Whenever you try to read to or writeįrom an address in memory, the hardware first checks with the operating The way memory works is as follows: The operating system allocatesĬertain pages of memory for you. On some machines, pages are 4096 bytes - this On the hydra machines, memory is broken up into 8192-byte chunks. Let's use the hydra machines as an example. There are many ways to memory management, fortunately,Īll UNIX systems use a pretty standard approach, called paging. Physical address space to meet the need by a large number of

#Memory note how to#

Memory management, which also include how to best use a limited This is part of the job done by OS in terms of Here, the operating system needs to map this virtual address space Phone numbers are just logical and canīe easily changed, while your street address is not. That might help you understand is the assignment of phone numbers TheseĪddresses are all virtual memory addresses. Or 0x8fffffff, depending on what type of system you are on. Memory address space that start from 0x0 and goes up to 0xffffffff With an operating system provides each process it loads with a Stack goes up as you make nested procedure calls. Note, the heap grows down as you make more malloc() calls, and the

memory note

If we view memory as a big array, the regions (or ``segments'') look The stack: This contains your local variables and procedure.The heap: This is memory that you get from malloc().The globals: These are your global variables (init data and bss).

#Memory note code#

The code (or "text"): These are the instructions of your program.This is Unix's way of telling you that that memory location isįor example, the following code will generate a segmentation violation:Īs it turns out, there are 4 regions of memory that are legal. Pointer with a value of 0, you will get a segmentation violation. Unfortunately, you cannot access all elements of memory. The memory array (memory being indexed starting with zero). Thus whenĪ C pointer is 0xefffe034, it points to the 0xefffe035th element in This lecture is an introduction to memory as we see it in Unix.Īs I have said previously, memory is like a huge array withĪ pointer in C is an index to this array. How whatever the machine you are on is laid out.Īlso, you should set up your shell so that you don't generateĬore files when doing this lecture. However, you should be able to figure out kenner, the hydra machines), you will likely If you try to go through the programs in this lecture on Memory The machine layout that I describe is that of the machines in the












Memory note