educative.io

In the example, how did all 4 programs run simultaneously

We used four commands separated by & and I always understood that second program would only run after first one has completed successfully. Since the program is infinite loop, how did all four programs separated by & ran at once ?

Hello @Abhishek_Vaid,

There is a difference between & and &&. When we chain commands using &, all the commands will run simultaneously. However, when we chain commands using &&, the commands will execute one by one. Each command will wait for the previous command to execute. To experiment this, try executing ls & pwd & date and ls && pwd && date

Hope this helps!

Salam
When I try to run the program in my ubantu i get different addresses why it so please if you can explain

Wa alaikum as-salam @Malik_Fahad_Sarwar

When working on your virtual machine, you will obviously receive an address unique to that machine, which will differ from the addresses provided.

Best Regards,
Happy Learning :slight_smile:


p1 have address that is different from p2 but here on website both process have same address
I mean that in my case why I don’t get the same address


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

Hi @Malik_Fahad_Sarwar
Can you please share the command which you are using for this?
Thanks!

@Muntha_Amjad


can you please explain why I get different address for p where as on website both processes have same address


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

@Malik_Fahad_Sarwar
In the lesson, it is clearly mentioned that:

So consider doing all the above-mentioned steps first then you will be able to see the exact output as mentioned in the lesson.

Thanks!

can you please tell how address-space randomization is working specially in my case and not giving the same address for both process
also can address-space randomization have any effect on virtualization


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

@Malik_Fahad_Sarwar
Address space randomization is a memory-protection process for operating systems that guards against buffer-overflow attacks by randomizing the location where system executables are loaded into memory.
Address space randomization is based upon the low chance of an attacker guessing the locations of randomly placed areas. Security is increased by increasing the search space. Thus, address space randomization is more effective when more entropy is present in the random offsets. Entropy is increased by either raising the amount of virtual memory area space over which the randomization occurs or reducing the period over which the randomization occurs. The period is typically implemented as small as possible, so most systems must increase VMA space randomization.

Hope it helps!

so we can say due to Address space randomizationI am not getting the same addresses right?
but if Address space randomization is enabled we are getting different address so how can we say that memory is virtualize because each process is getting different address not the same

@Muntha_Amjad


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

@Malik_Fahad_Sarwar
Please use the following command to disable address space randomization:
echo 0 > /proc/sys/kernel/randomize_va_space

Please note that you should set up a virtual machine and execute all such commands inside it in order to avoid any mishap with your own working machine. In case you decide to execute this command inside your own machine, please make sure to enable address space randomization back again using the following command:
echo 2 > /proc/sys/kernel/randomize_va_space

Hope it helps.
Thanks!

@Muntha_Amjad
sir i got it how to enable or disable randomization of address
But my point is due to Address space randomization I am not getting the same addresses right?
but if Address space randomization is enabled we are getting different address so how can we say that memory is virtualize because each process is getting different address not the same


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

@Malik_Fahad_Sarwar
Virtualization is not happening with different memory addresses as per your screenshot. According to the last paragraph of the lesson, virtualization occurs when processes are mapped to their own private address space. This then is mapped to the physical address. So even though the addresses might be the same, the events happening at each address will be independent.

@Muntha_Amjad
Yes my point is that virtualization happens when both process get their private address space As the program run on educative site both process get same address(logical address 0*20000) but their physical address is different
In my case according to screenshot both process get different address so we can say that virtualization is happening or not bz each process have different address

@Malik_Fahad_Sarwar
Yes, virtualization is happening. It does not matter whether the addresses are the same or different. The main purpose of showing the same addresses inside the lesson was to show that even though the addresses are the same, actions happening at each address are independent for the two processes.

Thanks!

Thanks a lot for your time
Just one more question as I perceive that virtualization is happening till the process gets their own private address space right? so basic purpose of virtualization of memory is to provide their own private address


Course: Operating Systems: Virtualization, Concurrency & Persistence - Learn Interactively
Lesson: Virtualizing Memory - Operating Systems: Virtualization, Concurrency & Persistence

@Malik_Fahad_Sarwar
Exactly.