1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
|
<HTML
><HEAD
><TITLE
>rtlinux_sigaction, rtlinux_sigprocmask</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"></HEAD
><BODY
CLASS="REFENTRY"
><H1
><A
NAME="AEN1"
>rtlinux_sigaction, rtlinux_sigprocmask</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN5"
></A
><H2
>Name</H2
>rtlinux_sigaction, rtlinux_sigprocmask -- RTLinux V3 User-Level signal handling functions.</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN8"
></A
><H2
>Synopsis</H2
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SYNOPSIS"
> #include <rtlinux_signal.h>
int <TT
CLASS="FUNCTION"
>rtlinux_sigaction</TT
>(int <TT
CLASS="PARAMETER"
><I
>signum</I
></TT
>, struct rtlinux_sigaction * <TT
CLASS="PARAMETER"
><I
>act</I
></TT
>, struct rtlinux_sigaction * <TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>);
int <TT
CLASS="FUNCTION"
>rtlinux_sigprocmask</TT
>(int <TT
CLASS="PARAMETER"
><I
>how</I
></TT
>, rtlinux_sigset_t * <TT
CLASS="PARAMETER"
><I
>set</I
></TT
>, rtlinux_sigset_t * <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
>);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN18"
></A
><H2
>DESCRIPTION</H2
><P
>This is introduced in V3 RTLinux.
The <TT
CLASS="FUNCTION"
>rtlinux_sigaction</TT
> function call is used to request
delivery of a real-time event and assign a handler for that event. Its
semantics are similar to <TT
CLASS="FUNCTION"
>sigaction(3)</TT
> for ease of
programming, but it does not affect or interact with normal Linux signals. The
handler is called as quickly as hardware allows and does not wait for Linux to
become ready (enabling interrupts, releasing locks and so on). Latencies
between the requested event and handler code being called is on the order of
a few tens of micro-seconds on modern hardware. This low-latency behavior
comes with restrictions listed in the NOTES section.</P
><P
><TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> specifies the signal number. Signal numbers 0 up to (but
not including) <TT
CLASS="LITERAL"
>RTLINUX_SIGTIMER0</TT
> are hardware IRQ's. So,
signal 3 represents IRQ 3. Signal numbers <TT
CLASS="LITERAL"
>RTLINUX_SIGTIMER0</TT
>
and above are timer events.</P
><P
>If <TT
CLASS="PARAMETER"
><I
>act</I
></TT
> is non-NULL, the new action for signal
<TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> is installed from <TT
CLASS="PARAMETER"
><I
>act</I
></TT
>.
Unlike with <TT
CLASS="FUNCTION"
>sigaction</TT
>, <TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
> is
ignored and may be NULL or non-NULL. The call to
<TT
CLASS="FUNCTION"
>rtlinux_sigaction</TT
> does not change or read
<TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>.</P
><P
>The <TT
CLASS="PARAMETER"
><I
>rtlinux_sigaction</I
></TT
> structure is defined as
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
> struct rtlinux_sigaction
{
void (*sa_handler)(int);
rtlinux_sigset_t sa_mask;
int sa_flags;
hrtime_t sa_period;
};</PRE
></TD
></TR
></TABLE
>
<TT
CLASS="PARAMETER"
><I
>sa_handler</I
></TT
> specifies the action to be associated with
<TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> and may be <TT
CLASS="LITERAL"
>RTLINUX_SIG_DFL</TT
>
for the default action, <TT
CLASS="LITERAL"
>RTLINUX_SIG_IGN</TT
> to ignore the
signal, or a pointer to a signal handling function.</P
><P
><TT
CLASS="PARAMETER"
><I
>sa_period</I
></TT
> is the period (in nanoseconds) between signals
sent to the process when <TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> is
<TT
CLASS="LITERAL"
>RTLINUX_SIGTIMER0</TT
> or above. Only one timer signal will
be delivered in <TT
CLASS="PARAMETER"
><I
>sa_period</I
></TT
> nanoseconds when
<TT
CLASS="LITERAL"
>RTLINUX_SA_ONESHOT</TT
> is set in
<TT
CLASS="PARAMETER"
><I
>sa_flags</I
></TT
>. If <TT
CLASS="LITERAL"
>RTLINUX_SA_ONESHOT</TT
> is
not set then the signal handler is automatically reinstalled each signal
delivery (this is the default behavior).</P
><P
><TT
CLASS="PARAMETER"
><I
>sa_flags</I
></TT
> specifies a set of flags which modify the
behavior of the signal handling process. It is formed by the bitwise OR of
zero or more of the following:
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>RTLINUX_SA_ONESHOT</TT
> or
<TT
CLASS="LITERAL"
>RTLINUX_SA_RESETHAND</TT
></DT
><DD
><P
>Restore the signal action to the default state once signal
handler has been called. (NOTE: <TT
CLASS="LITERAL"
>RTLINUX_SA_ONESHOT</TT
> and
<TT
CLASS="LITERAL"
>RTLINUX_SA_RESETHAND</TT
> have the same value; read
<TT
CLASS="LITERAL"
>RTLINUX_SA_RESETHAND</TT
> as "reset the handler to the default
handler after the specified handler is called".)</P
></DD
><DT
>RTLINUX_SA_PERIODIC</DT
><DD
><P
>Re-install the specified signal handler each signal delivery
(default behavior).</P
></DD
></DL
></DIV
> </P
><P
>The <TT
CLASS="FUNCTION"
>rtlinux_sigprocmask</TT
> call is used to change the list
of currently blocked RTLinux signals, similar to
<TT
CLASS="FUNCTION"
>sigprocmask</TT
> in libc. The behavior of the call is
dependant on the value of <TT
CLASS="PARAMETER"
><I
>how</I
></TT
>, as follows.
<P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>RTLINUX_SIG_BLOCK</TT
></DT
><DD
><P
>The set of blocked signals is the union of the current set and
the <TT
CLASS="PARAMETER"
><I
>set</I
></TT
> argument.</P
></DD
><DT
><TT
CLASS="LITERAL"
>RTLINUX_SIG_UNBLOCK</TT
></DT
><DD
><P
>The signals in <TT
CLASS="PARAMETER"
><I
>set</I
></TT
> are removed from the
current set of blocked signals. It is legal to attempt to unblock a signal
which is not blocked.</P
></DD
><DT
><TT
CLASS="LITERAL"
>RTLINUX_SIG_SETMASK</TT
></DT
><DD
><P
>The set of blocked signals is set to the current argument
<TT
CLASS="PARAMETER"
><I
>set</I
></TT
>.</P
></DD
></DL
></DIV
> </P
><P
>If <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
> is non-NULL, the previous value of the signal
mask is stored in <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN92"
></A
><H2
>RETURN VALUES</H2
><P
><TT
CLASS="FUNCTION"
>rtlinux_sigaction</TT
> and
<TT
CLASS="FUNCTION"
>rtlinux_sigprocmask</TT
> return 0 on success and -1 on error.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN97"
></A
><H2
>ERRORS</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>EINVAL</DT
><DD
><P
>An invalid signal was specified.</P
></DD
><DT
>EFAULT</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>act</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>,
<TT
CLASS="PARAMETER"
><I
>set</I
></TT
> or <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
> point to memory
which is not a valid part of the address space.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN112"
></A
><H2
>NOTES</H2
><P
>This function is only available in Linux user processes. RTLinux threads can not use this function.</P
><P
>It is necessary for the RTLinux modules to be loaded for these calls to
succeed.</P
><P
>During a call to rtlinux_sigaction, <TT
CLASS="FUNCTION"
>mlockall</TT
> is called so
currently swapped-in pages and future pages will be locked in memory until
this process exits or unlocks its pages. As a result, this call will only
succeed when made from a process running as root.</P
><P
>The handler assigned in the call to <TT
CLASS="FUNCTION"
>rtlinux_sigaction</TT
>
will be scheduled and executed by RTLinux and may be run when Linux is
unable to provide normal services to the executing code. So, all
calls made in the signal handler must be to statically linked libraries;
code within the program itself cannot execute system calls. To have services perform the needed actions, one should send requests to the non-RTLinux signal handler
part of the program.</P
><P
>Currently, in addition to its own address space, the handler executes with the kernel memory mapped in and accessible (the same as that of
the parent), so programmers must take care to not change kernel data
structures. This feature allows access to device address space as well.</P
><P
>Since RTLinux signals represent either IRQs or real-time timers, blocking an
RTLinux signal will pend the IRQ or timer to which it corresponds. Blocking an IRQ
will keep track of how many times that IRQ goes off, then call the installed
handler that many times when the IRQ is unblocked. When a timer is blocked
and then unblocked, the installed handler will only be called once if the the
timer went off one or more times while blocked.</P
><P
>To manipulate RTLinux signal sets (rtlinux_sigset_t) use the
<TT
CLASS="FUNCTION"
>rtlinux_sigsetops</TT
>(3).
To see which RTLinux signals are available, see
<TT
CLASS="FUNCTION"
>rtlinux_signal</TT
>(3).</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN125"
></A
><H2
>EXAMPLES</H2
><P
>See the RTLinux distribution examples/psc directory for further examples.</P
><P
><TT
CLASS="FUNCTION"
>request_irq()</TT
> functionality can be implemented as:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
> struct rtlinux_sigaction sig, oldsig;
int irq = 4;
void handler_function(int);
sig.sa_handler = handler_function;
sig.sa_flags = RTLINUX_SA_PERIODIC;
if ( rtlinux_sigaction( irq, & sig, & oldsig ) )
{
printf("Couldn't get irq\n");
perror("rtlinux_sigaction");
return -1;
}</PRE
></TD
></TR
></TABLE
></P
><P
><TT
CLASS="FUNCTION"
>free_irq()</TT
> functionality can be implemented with:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
> struct rtlinux_sigaction sig, oldsig;
int irq = 4;
sig.sa_handler = RTLINUX_SIG_IGN;
/* free the irq */
rtlinux_sigaction( irq, & sig, & oldsig );</PRE
></TD
></TR
></TABLE
> </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN134"
></A
><H2
>AUTHORS</H2
><P
>Cort Dougan (<A
HREF="mailto:cort@fsmlabs.com"
TARGET="_top"
>cort@fsmlabs.com</A
>)</P
><P
>Nathan Paul Simons (<A
HREF="mailto:npsimons@fsmlabs.com"
TARGET="_top"
>npsimons@fsmlabs.com</A
>)</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN140"
></A
><H2
>SEE ALSO</H2
><A
HREF="../susv2/xsh/sigaction.html"
TARGET="_top"
>UNIX spec sigaction(2)</A
>, <A
HREF="../susv2/xsh/sigprocmask.html"
TARGET="_top"
>UNIX spec sigprocmask(2)</A
>, <A
HREF="rtlinux_sigsetops.3.html"
TARGET="_top"
>rtlinux_sigsetops(3)</A
>, <A
HREF="rtlinux_signal.3.html"
TARGET="_top"
>rtlinux_signal(3)</A
><P
>2001 FSMLabs Inc.</P
><P
>All rights reserved.</P
></DIV
></BODY
></HTML
>
|