• thread management'ta da shared memory space'inin kullanimina izin vermek icin kullanilan bir yontemdir. shared space'i maximum n adet thread'e limitlemek gerektigi zaman kullanilir. (bkz: mutex)
  • semaforun anlık değeri processin çalışma sırasını belirler.iki temel fonksiyonu vardır. signal() semaforu arttırır , wait() azaltır. multiprocessor sistemlerde semaforlar 0'dan düşük değerler alabilir.
  • solaris sistemlerde /etc/system file'ı içerisinden sayisi belirlenebilir.
  • deadlock'a yol açma riski olduğundan dikkatli kullanılması gereken senkronizasyon edevatı.
    (bkz: dining philosophers problem)
    teorik olarak anlatılırken wait() yerine p(), signal() yerine v() kullanılır zira dijkstra babamız da böyle kullanmıştır.
    v , hollandaca'da "arttırmak" anlamına gelen "verhoog"dan, p ise "azaltmaya çalışmak" manasına gelen "probeer te verlagen"ın hibriti "prolaag"tan gelmekte imiş. bu da işin geyik kısmı.
  • ispanyolca varyantı semáforo'dur ve trafik ışığı anlamına gelir. etimolojik olarak bakarsak,
    sema + phoro = işaret + tutan
    ingilizce'de el ve bayraklar kullanarak iletişim kurma yöntemi anlamına gelir.
  • yeni albüm hey ma 'dan bir james parçası

    i may as well try semaphore
    as words no longer work
    this fool was feeling cornered
    and he acted like a jerk
    he’d tell you he was sorry
    if that made good the hurt
    it’s too late now for sorry
    it’s too late now for words

    we survive
    despite our desire to stray
    hell to pay
    thought you knew
    my desires
    innate it’s not going away
    i hope you’re not going away

    it’s a question of convenience
    how pain, with time, will fade
    surrendered to acceptance
    dark night gives way to day
    it was meant to be a gesture
    that mark across your face
    it’s too late now for sorry
    it’s too late now for grace

    we survive
    despite our desire to stray
    hell to pay
    thought you knew
    my desires
    innate it’s not going away
    hell to pay
    thought you knew
    hell to pay
    thought you knew
    thought you knew
    thought you knew
  • lock ve mutex'in aksine senkronize erişimi tamamen bekletmek için değil sınırlandırmak için kullanılabilir denilebilir...sınırlı bir resource a sahipsiniz,aynı anda 3 thread'in bu kaynağa erişmesini istiyorsunuz daha fazlası sizin için bir sorun oluşturuyor..kodun o kısmını bütün thread'lerin kullanımına açmıyorsunuz,orada sayaca sahip bir lock kullanıyorsunuz..işte semaphore bu..
  • otel örneğiyle açıklanması yerindedir bence. otelin resepsiyoncusu semaphore'u odaları müşterilere vermek için kullanır. aklında otel tamamen boşken otelde kaç odanın müsait olduğunu tutar, ki bu otelin oda sayısıdır. müşteri geldikçe aklındaki bu oda sayısını düşürür, insanlar çıkış yaptığında bu sayıyı arttırır. bu rakam sıfıra ulaştığında boşta odasının olmadığnı ve isterlerse lobide beklemelerini söyler. bu bekleyenler sırayla alınırlar, tabi resepsiyoncu bu insanlara statü veya para gibi etkenlere bağlı öncelikler vermediyse.

    tabi bir de iki durumlu semaphore vardır. bunu da anlatmak için tek odalı teorik bir otel yaratmak istedim çünkü bu tip semaphore'u unutmuştum ben bu örneği uydururken. burada resepsiyoncunun işi daha kolaydır çünkü oda ya tutulmuştur ya da tutulmamıştır. yine aynı sistemle resepsiyoncu odayı tutmak isteyen müşterileri bu anlamsız tek odalı otelin lobisinde bekletir.
  • şöyle bir örneklendirme ve açıklaması da olabiliyor:

    is the number of free identical toilet keys. example, say we have four toilets with identical locks and keys. the semaphore count - the count of keys - is set to 4 at beginning (all four toilets are free), then the count value is decremented as people are coming in. if all toilets are full, ie. there are no free keys left, the semaphore count is 0. now, when eq. one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next person in the queue.

    officially: "a semaphore restricts the number of simultaneous users of a shared resource up to a maximum number. threads can request access to the resource (decrementing the semaphore), and can signal that they have finished using the resource (incrementing the semaphore)."
    ref: symbian developer library

    http://pheattarchive.emporia.edu/…vs_ semaphore.htm
  • integer ve özel bir değişkendir. critical sectiona girmek ne zaman uygundur, ne zaman uygun değildir buna karar verir. hiçbir zaman negatif değerle ilklendirilemez. wait ve signal işlemleri yapar.
hesabın var mı? giriş yap