06. Memory

Command line

E. g. (try i):

less:

maan:

seq:

Static Memory allocation

What this code does?

   1 #include <stdio.h>
   2 
   3 int A[5];
   4 int B[5];
   5 
   6 int main(int argc, char *argv[]) {
   7   int i=0;
   8   do
   9         scanf("%d", &A[i++]);
  10   while(A[i-1]);
  11 
  12   for(i=0; i<5; i++)
  13         printf("%d ", A[i]);
  14   for(i=0; i<5; i++)
  15         printf("%d ", B[i]);
  16   putchar('\n');
  17 
  18   return 0;
  19 }

Compile it statically:

Try it:

Dynamic memory allocation

Important: while memory/stack corruption is deadly for a process, it is completely safe for other processes, because of memory isolation

H/W

HSE/ProgrammingOS/Lab_06_Memory (последним исправлял пользователь FrBrGeorge 2020-02-14 09:46:26)