Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
SFML Blueprints

You're reading from   SFML Blueprints Sharpen your game development skills and improve your C++ and SFML knowledge with five exciting projects

Arrow left icon
Product type Paperback
Published in May 2015
Publisher Packt
ISBN-13 9781784398477
Length 298 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

What is multithreading?

In computer science, a software can be seen as a stream with a start and exit point. Each software starts its life with the main() function in C/C++. This is the entry point of your program. Until this point, you are able to do whatever you want; including creating new routine streams, cloning the entire software, and starting another program. The common point with all these examples is that another stream is created and has its own life, but they are not equivalent.

The fork() function

This functionality is pretty simple. Calling fork() will duplicate your entire running process to a new one. The new process that is created is totally separated from its parent (new PID, new memory area as the exact copy of its parent), and will start just after the fork() call. The return value of the fork() function is the only difference between the two executions.

Following is an example of the fork() function:

int main()
{
  int pid = fork();
  if(pid == -1)
    std::cerr<&lt...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime