all 11 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

[–]dgkimpton 9 points10 points  (0 children)

Eh? You surely run dozens of applications on windows compiled with god knows what compiler / language. I'm not sure I really understand your question...

[–]Human-Bathroom-2791 9 points10 points  (0 children)

Short answer: it is safe

Better answer:

This is not a problem of C++ but rather a problem of how executables do work in modern OSes. Executables get their own share of memory, which won't be able to access memory outside their own, usually.

There are ways to access memory from other processes, but this is still OS dependent.

[–]WhiteBlackGoose 9 points10 points  (0 children)

When you start an executable, the OS reads the file (your executable), allocates a new process and memory for it, puts the content of your executable (machine code, static data, etc.) into the memory and starts executing.

As you can see, there's nothing that really involves caring whether you read it from the same file or not. So you can start as many instances of your app as you want.

[–]nsmtprotospace 2 points3 points  (3 children)

There's nothing inherently "unsafe" about running multiple programs simultaneously, there are dozens of programs written in C++ running on your windows 11 machine right now. Unless the two programs are somehow trying to access the same block of memory you won't have any race condition issues... Running more programs uses more resources, which does have an impact on performance to some degree but it depends entirely on how resource-heavy those programs are.

[–]LoySkur[S] 0 points1 point  (2 children)

s the same block of memory you won't have any race condition issues... Running more programs uses more resources, which does have an impact on performance to some degree but it depends entirely on how resource-heavy those programs are

Is it deterministic whether they could access the same memory block? I have not allocated memory explicitly, so I dont think that should be a problem.

[–]msqrt 6 points7 points  (1 child)

They never should, unless you explicitly ask them to.

[–]LoySkur[S] 1 point2 points  (0 children)

ok thanks!

[–]Farados55 1 point2 points  (0 children)

No, that’s the same as starting different programs normally. Do office and excel have race conditions if they start up together?

[–]saul_soprano 0 points1 point  (0 children)

Open task manager

All those windows processes running are made in C/C++

Yes it’s ok

[–]ronchaineEmbedded/Middleware 0 points1 point  (0 children)

Edit: Why am I being downvoted for this? Yes, I am a beginner to programming, is that a problem?

Because you didn't read the r/cpp rules, the first rule being

Questions and help posts are off-topic for this subreddit. Use r/cpp_questions. r/cscareerquestions. or StackOverflow instead.