Unix-system-calls-getcontext

提供:Dev Guides
移動先:案内検索

[top]#

|http://www.google.com/[Google] | a|

Web This Site
  • 初心者向けのUnix *
  • 高度なUnix *

選択した読書

Copyright©2014 by finddevguides

[cols=",,,,,,,",]

| |  Home   | |  References   | |  Discussion Forums   | |  About TP  

[width="100%",cols="100%",]

a| == getcontext()-Unix、Linuxシステムコール

[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]

広告

NAME

getcontext、setcontext-ユーザーコンテキストの取得または設定

概要

  • #include <ucontext.h> *
  • int getcontext(ucontext_t * ucp ); * * int setcontext(const ucontext_t * ucp ); *

ここで、

Tag Description
ucp points to a structure defined in <ucontext.h> containing the signal mask, execution stack, and machine registers.

説明

*getcontext* (2)は、呼び出しプロセスの現在のコンテキストを取得し、_ucp_が指すucontext構造体に保存します。
*setcontext* (2)は、呼び出しプロセスのコンテキストを、_ucp_が指すucontext構造体に格納されている状態に設定します。 構造体は、 *getcontext* (2)によって作成されているか、 *sigaction* (2)シグナルハンドラーの3番目のパラメーターとして渡されている必要があります。
*getcontext* (2)によって作成されたucontext構造体は、次のように<ucontext.h>で定義されます。
typedef struct ucontext { unsigned long int uc_flags; struct ucontext *uc_link; stack_t uc_stack; mcontext_t uc_mcontext; __sigset_t uc_sigmask; struct _fpstate __fpregs_mem; } ucontext_t;

返り値

*getcontext* (2)は成功すると0を返し、失敗すると-1を返します。 *setcontext* (2)は成功すると値を返さず、失敗すると-1を返します。

規格

これらの関数は、XPG4-UNIXに準拠しています。

ノート

シグナルハンドラが実行されると、現在のユーザーコンテキストが保存され、カーネルによって新しいコンテキストが作成されます。 呼び出しプロセスが longjmp (2)を使用してシグナルハンドラを離れる場合、元のコンテキストは復元できず、 getcontext (2)への今後の呼び出しの結果は予測できません。 この問題を回避するには、シグナルハンドラで longjmp (2)の代わりに siglongjmp (2)または setcontext (2)を使用します。

関連項目

*sigaltstack* (2)、 *sigprocmask* (2)、 *sigsetjmp* (3)、 *setjmp* (3)。 http://www.finddevguides.com/unix_system_calls/index[image:http://www.finddevguides.com/previous.gif[previous]] http://www.finddevguides.com/unix_system_calls/index[image :http://www.finddevguides.com/images/next.gif [next]] http://www.finddevguides.com/cgi-bin/printversion.cgi?tutorial=unix_system_calls&file=getcontext[image:http://www.finddevguides.com/print.gif[Printer Friendly]]

広告

|  

[cols="^",]

|Advertisements