Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Extreme C

You're reading from  Extreme C

Product type Book
Published in Oct 2019
Publisher Packt
ISBN-13 9781789343625
Pages 822 pages
Edition 1st Edition
Languages
Author (1):
Kamran Amini Kamran Amini
Profile icon Kamran Amini
Toc

Table of Contents (23) Chapters close

1. Essential Features 2. From Source to Binary 3. Object Files 4. Process Memory Structure 5. Stack and Heap 6. OOP and Encapsulation 7. Composition and Aggregation 8. Inheritance and Polymorphism 9. Abstraction and OOP in C++ 10. Unix – History and Architecture 11. System Calls and Kernels 12. The Most Recent C 13. Concurrency 14. Synchronization 15. Thread Execution 16. Thread Synchronization 17. Process Execution 18. Process Synchronization 19. Single-Host IPC and Sockets 20. Socket Programming 21. Integration with Other Languages 22. Unit Testing and Debugging 23. Build Systems

Happens-before constraint

We established in the previous section that context switches are not predictable; there is uncertainty about the time at which they are likely to occur in our programs. Despite that, there is certainty about the instructions that are being executed concurrently.

Let's continue with a simple example. To start with, we're going to work on the basis that we've got a task like the one you see next in Code Box 13-1, which has five instructions. Note that these instructions are abstract, and they don't represent any real instructions like C or machine instructions:

Task P {
    1. num = 5
    2. num++
    3. num = num – 2
    4. x = 10
    5. num = num + x
}

Code Box 13-1: A simple task with 5 instructions

As you can see, the instructions are ordered, which means that they must be executed in that specified order in order to satisfy the purpose of the task. We are certain about this. In technical terms, we say that we have...

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 $15.99/month. Cancel anytime}