Skip to content

An attempt to solve a simple Synchronization problem using various programming languages

Notifications You must be signed in to change notification settings

vinayakakv/semaTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

semaTest

A simple synchronization problem is as follows

The following Program consists of 3 concurrently running Threds and 3 Binary Semaphores. The Semaphores are initialized as follows, S0 = true, S1 = false and S2 = true

The executable section of the codes are as follows

T0:

while(!false) {
	wait(S0);
	print("0");
	signal(S1);
	signal(S2);
}

T1:

wait(S1);
signal(S0);

T2:

wait(S2);
signal(S0);

How many times will the process print "0" ?

  1. At least Twice
  2. Exactly Twice
  3. Exactly Thrice
  4. Exactly Once

An attempt to solve this program using C#,Java,Python,C++,C and x64 Assembly is Presented here.

x64 assembly uses the code from [Pure assembly, library-free Linux threading demo] (https://github.com/skeeto/pure-linux-threads-demo/blob/master/threads-x86_64.s)

NOTE

Multi Processing Solutions are yet to be prepared.

About

An attempt to solve a simple Synchronization problem using various programming languages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published