Semaphore use in signals

オープン
#262 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp

調査の方向性

ファイルやテストは指定されていません。まず、interprocess_semaphore が使用するセマフォ実装、特に spin パスと POSIX パス、および timed_wait が SIGINT とどのように相互作用するかを追跡してください。プロジェクトで、例外を送出しない POSIX post と、コンパイル時のシグナル安全性に関する情報について設計が確定していれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I am using interprocess' semaphore in conjunction with timed_wait, and I need to be able to handle SIGINT to terminate the waiting early. Looking into the implementation, I can see that I am getting the spin semaphore internally, which suggests to me that post()ing it from the signal handler is safe, since it is effectively just an atomic increment.

This would likely not hold in other types of internal implementations of the semaphore. For example, while POSIX implementation seems to be fine in the first line (it just uses sem_post), it can later throw an exception.

This leads me to two thoughts:

  1. Can we have a variant of the POSIX post() that would not throw an exception?
  2. Can we add compile-time introspection for signal safety of the chosen semaphore implementation? So that one can do something like static_assert(boost::interprocess::interprocess_semaphore::signal_safe_post).

I am happy to contribute such improvements if there's a consensus.

主要言語
C++
スター
185
フォーク
131
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/interprocess のほかの issue

boostorg/interprocess の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。