Question

How is the seperation of multiple instances of the same project/program done, that means which mechanism seperates the data of two instances of the same project/program?

Edit: Examples:

  1. When using a write program two times and working with FILE1 and FILE2. How do most OS seperate the two instances? As I have read in the comments the files get different memory blocks. Do the memory blocks "get" the name of the files, like block143 can be adressed by FILE1 and block223 can be addressed by FILE2?
  2. Simulation: If I call one simulation type (same commandline arguments) on two different data input files. How does the OS seperate those files concerning the addressing of the different memory blocks/instances?

greetings streight

Was it helpful?

Solution

An answer from the discussion above :

The OS assigns each program or an instance of a program a certain block of memory. Have you ever tried accessing random memory? Most of the time your program would crash. This is due to OS handling. If you access memory not assigned to you, the OS automatically crashes your program (security feature).

There is a separate memory for the program and the memory that the program uses. The memory given to the program to run (space required by the class/function name etc... ) is separate from any variables you would assign during runtime.

This is all assuming that your OS does support multiple processes executing in parallel - very old or very limited embedded systems may not even support this at all. A lot of boards you work on (in school) do not support something like this and you have to write it on your own.

When you call the same program with separate files, each file exists within it's own memory space. No, they are not labelled as such. Do not try to guess what the names are after compilation. It just doesn't work.

why?

1)It's compiler dependent. Different compilers use different ways.

2)It's not human readable (unless your write the compiler yourself)(Correct me if I'm wrong)

The OS/compiler gives them a unique name (could be time dependent, os dependent or a a hundred other things). The programs do not know about each other and run in their own space.

Credit : @Hulk @Mohammad Ali Baydoun

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top