Skip to Content
Author's profile photo SivaKumar Kilari

What is Semaphore? ( SM50, sem)

What is Semaphore?

In computer science, particularly in operating systems, a semaphore is  a variable or abstract data type that is used for controlling access,  by multiple processes, to a common resource in a parallel programming or a multi user environment.

What do the semaphores mean in SAP?


In trace files or in transaction SM50 (process overview),

Semaphores are mentioned. How do you determine which semaphores control what?


Reason and Prerequisites ?


If a work process locks a particular resource, it sets a semaphore. Another work process that also wants to access it must then wait. In this case, the number of semaphores is displayed by SM50.

Example: if any user while login (6: ROLL_ADM (roll administration)) semaphore will be locked, semaphore 6 is set.


How to Monitor Semaphores ?


Using SM50 transaction code. Find below screen shots.

/wp-content/uploads/2014/03/1_416628.png

Find below screen shot , How to see all the sap related semaphores by pressing F1 key.

/wp-content/uploads/2014/03/2_416629.png

In Operating system level ( MMC ) also you can observe in sem column (10 & 4 )

/wp-content/uploads/2014/03/3_416872.png

Thanks

Shiva Kumar

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      very good document and useful.

      regards,

      meher

      Author's profile photo Former Member
      Former Member

      well - nice document!

      To be added:

      1. semaphores are used to synchronize concurrent access to shared resource (mostly shared memory) to avoid corruptions.
      2. In the MMC the current semaphore holder has a negativ semaphor value, waiters a positiv one. Only one semaphore per process can be shown in SM50 - but a process can hold more than one semaphore at a time.

      This document is not windows specific. Therefore I am going to move it to the appropriate area within the next days.

      regards

      Peter

      Author's profile photo SivaKumar Kilari
      SivaKumar Kilari
      Blog Post Author

      Thanks peter

      I am unable to capture those (but a process can hold more than one semaphore at a time) screen shots.  I will try to capture and I will put here.

      Author's profile photo Former Member
      Former Member

      Very Good Docuemntation

      Author's profile photo Former Member
      Former Member

      Nice..

      Author's profile photo Rahul Vhankore
      Rahul Vhankore

      The semaphore column in SM50 / SM66 tells you whether that work process is holding a semaphore, or waiting for one, if the field is blank (which should be most of the times) then the work process is not holding nor waiting for a semaphore.

      the WP requires a semaphore only when it will execute a very specific part of its code like -

      for example, let us say that WP10 reached a part of the code where it will change the "roll administration" shared memory area before doing any changes, it will request semaphore 6

      if it was able to lock semaphore 6, it proceeds and perform the change in the "roll adm" memory
      releasing the semaphore soon after, so other WPs can get it, if / when required. But if WP could not get the lock, it will keep trying but this should be very, very fast on a normal running system, it would be almost impossible to see a semaphore in SM50

      Semaphores are OS level resources that we use to protect the execution of critical code in the kernel, ensuring that only a single process is executing that code at a time
      this is normally related to changing shared memory areas. 

       

      Regards,

      Rahul Vhankore