Posts

Showing posts from November, 2015

Object oriented programming (Introduction) - Article 1

Hi Folks, Let's start off on OOP and C++. This is an introductory article for the bigger things coming in the future weeks. What is OOP or Object oriented programming? OOP stands for object oriented programming. C#, C++ and Java are examples of object oriented languages, where as C, Pascal are examples of procedural languages. Modularity, extensibility, reusability and maintainability are some of the advantages of OO languages. In OOP, the software programs are organized as OBJECTs. All the entities in OOP are modelled as objects. Suppose a problem is given, in procedural langauge like C, the problem is divided into functions (actions on data) and data are declared, whereas in C++, the problem is modelled as objects. For example, a problem on car in C will look like, float brake; float acceleration; main() {     accelerate_the_car();         if(obstacle == true)             apply_brake(); } void accelerate_the_car() { } void appl

Synchronization primitives: Mutex and Semaphore (Differences between Mutex and Semaphore) - Article 12

Hi Folks, Sorry, had to take a long break. In this article, let's summarize the differences between Mutex and Semaphore and this is the last article in the series. In the coming articles we shall discuss more about OO, Design, C++, etc and revisit synchronization as and when needed. Mutex Semaphore 1 Mutex is a locking mechanism only to ensure mutual exclusion, that is only one thread or process is allowed to execute the code in critical section. Semaphore can be used for locking, signalling and variety of problems as we have seen in the examples. 2 Mutex is owned and only thread that has locked the mutex can unlock it. Semaphore does not have ownership, anybody can unlock a semaphore. 3 Process wide. System wide. 4 Mutex is used to synchronize threads. Semaphore is used to synchronize threads/processes. 5 Simpler to use. Complex semantics. To