boostorg / boostorg/interprocess

Semaphore use in signals

オープン
#262 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
185
フォーク
131
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

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

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

調査の方向性

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

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

評価

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

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

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