
PPT Attachedon 12 May 2024
Set up a posix-compliant environment on Linux or macOS, using Ubuntu in a VMware VM, fork the repository on GitHub, and use Visual Studio Code for code access.
Explain synchronous versus asynchronous programming through a cake-making example, highlighting how parallel steps avoid waiting. Show how signals notify completion and prevent blocking so tasks run independently.
Explore the difference between asynchronous and multithreading, learn how to implement single-threaded and multi-threaded asynchronous designs, and manage tasks like network packets, timer callbacks, and user requests.
Explore four models of synchronous and asynchronous computation by solving sum and multiplication tasks on a 10-element integer array, including asynchronous single-threaded and asynchronous multi-threaded designs with task subdivision.
Adopt a fast-track, hands-on course on asynchronous design patterns by building an event loop (dispatch queue) and applying language-agnostic concepts, with libuv as an example.
Explore the design and implementation of an event loop, a multipurpose asynchronous data structure that schedules computations, and build an event loop library for various async models.
set up a posix-compliant linux environment, such as ubuntu 20.04 in a vm, fork the course repository on github, and use gcc for c/c++ demonstrations.
Design and implement an event loop mini library by defining task structures as function pointers with arguments, using a linked-list queue, mutexes, a condition variable, and a POSIX thread.
Refer to Appendix Section A if you want to refresh how a typical producer - consumer pattern is implemented before going through this lecture video.
Demonstrates single-threaded concurrency by using an event loop to run upload and download tasks in parallel, illustrating task scheduling, context switching, and that tasks remain invisible to the operating system.
Copy pasted from Multi-threading Course.
Integrate an event loop in a c/c++ project by creating the loop object, packaging routing table updates as a single job, and updating via a callback.
Explore asynchronous programming design patterns in C/C++ by adding expiration timers to routing table entries, using timer setup and callbacks for millisecond expiration to delete expired entries and prevent leaks.
Explore how the event loop schedules asynchronous computations, dequeueing tasks from its queue to enable concurrency in a single threaded program while avoiding forced multithreading.
By the end of this section, the Src code snapshot would be pointed to by this git hashcode : 03a29fa1b0bbf83ec7219e6f1bd65a3b2be35ccd
How to setup this commit hashcode, pls follow the below steps :
Download git repo :
https://github.com/sachinites/AsyncProgramming
Set the git head to above hash code
git reset --hard 03a29fa1b0bbf83ec7219e6f1bd65a3b2be35ccd
now, you can browse the code of this repo when this section was completed.
To come back to latest commit :
git pull
To see the solution, visit the link :
https://github.com/sachinites/AsyncProgramming/commit/d09e4de5e25e38353377701dffffb1b6805dad16
Understand premature deletion in asynchronous programming, where deleting a data object with pending tasks creates a dangling pointer and may crash the program; learn a graceful method to handle it.
Implement asynchronous single routing table entry deletion in the STP process, using low priority tasks to prevent premature deletion, detach from the routing table, and safely release resources.
Learn how to safely delete an entire routing table in an asynchronous environment by isolating the routing table, launching a low-priority delete task, and deleting a linked list without interference.
Showcases asynchronous deletion of a routing table (a doubly linked list) via delete tasks scheduled at the lowest event-loop priority, deleting ten entries per preempted batch.
Explore why concurrency remains essential in multithreaded systems by examining how 100 threads share 16 CPUs, achieving a hybrid of concurrency and parallelism for better performance.
Design a multi-threaded process when work can be split into independent chunks, using worker threads to service each client and delegating work for isolation of server and client communications.
Create and start two UDP listener threads on localhost, ports 3000 and 3001, passing received packets to the main application via a packet receive function.
Welcome to the World of Asynchronous Programming!!
Asynchronous programming is used anywhere where your application interacts with other external entities - be it other threads, other processes. This world by its nature is Asynchronous. Asynchronous literally means - anything can happen anytime - unpredictable. How do you write software through Asynchronous programming? That's what we shall be going to learn in this course. Big software projects of reasonable sizes are Asynchronous. Software projects leave their synchronous boundaries the moment it starts integrating and communicating with external entities or go multithreaded.
Asynchronous programming is widely used in Distributed Systems, Networking Protocols, Distributes Databases, etc.
The prerequisite of this Course :
Know Thread Synchronization Concepts - Mutexes and Condition Variables ( any thread library, but we will be using pthreads )
C or C++ in preferable, but if your fav language is any other mainstream language then also it is ok. Borrow the concepts and implement it in your fav language.
Comfortable with basic Data structures such as Linked-List.
Zeal to learn and excel - beyond what Crowd is doing ( DS/ALGO/CP )
The end product of this Course shall be a mini library yet very powerful library which allows you do develop software through Asynchronous programming.
Course Difficulty Level :
The Course is level is Intermediate to Advanced. Very beginners pls refrain from enrolling into the Course.
Software Designing Problems to Address in this Course :
Problem 1. Simulating Concurrency in Single-Threaded Programs
problem 2. Reducing Multi-threaded Programs to Single Threaded
Problem 3. Work Deferrals
Problem 4. Asynchronous Communication
Problem 5. Queuing and Processing Incoming Network Packets
Good luck ! Happy Learning.
After doing this course You would understand :
Problems with Synchronous programming
Design and Implement Asynchronous Application/Softwares
What type of applications/softwares must not be multi-threaded
What type of applications/softwares must be asynchronous
Say good bye to locking and thread synchronization for forever.
The Concepts you would learn in this course are portable to other programming languages of your choice