Sponsored Content
Full Discussion: Basic signal and alarm usage
Top Forums Programming Basic signal and alarm usage Post 302119369 by porter on Tuesday 29th of May 2007 01:18:34 PM
Old 05-29-2007
Quote:
Originally Posted by Perderabo
prototypes are a good idea but are never required in c.
Not true, they *are* required if the function has not already been seen and returns anything other than an int. This is true even in K&R C.

Two examples why....

1. if the function returns a double some architectures require an FPU pop even if the value is not used.

2. if the function returns a struct it requires a certain amount of extra stackspace to be allocated in addition to an extra hidden pointer.

Finally,

If using GNU C use the options -Wall and -Werror, they actually help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Alarm signal

Hi, when I execute a script on unix AIX, I've got an error message: "Execution: 85328 Signal d'alarme". If I edit this file with "vi", I ve got the same error after a while (about 1 minute). If I try with another user I still have the problem. But if I rename this file, no problem. My... (5 Replies)
Discussion started by: cgsteph
5 Replies

2. Shell Programming and Scripting

Perl alarm signal

I am trying to write a signal to exit when a process times out. What I have come up with from poking around the web is this. #!/usr/bin/perl eval { local $SIG{ALRM} = sub { die "alarm clock restart" }; alarm 10; open(DSMADMC, "dsmadmc -se=tsmpc1 -id=XXXXX... (2 Replies)
Discussion started by: reggiej
2 Replies

3. AIX

basic question about disk usage

how to i find out the disk usage on a server. say in windows examples its like C:/ D:/ and checking out the disk space. how can i find in Unix. can i just use df -k (3 Replies)
Discussion started by: karthikosu
3 Replies

4. Shell Programming and Scripting

Basic bash 'for loop' usage

Hi! I have a simple question about using a for loop. I'm trying to open up all the zip files in the currect directory with ark, but I am getting the error "bash: syntax error near unexpected token `for $i ; do ark $i ; done ; I looked in the info pages for bash, but I can't seem to figure... (2 Replies)
Discussion started by: Orange Stripes
2 Replies

5. Programming

Usage of exit() inside a signal handler

Is it ok to use exit() inside a signal handler? I catch SIGUSR1 in a signal handler and I try to close a file and then exit. The result is inconsistent. Sometimes the process exit and sometimes it returns to the original state before the signal handler was invoked. Perhaps exit is not legal in... (8 Replies)
Discussion started by: Tuvia
8 Replies

6. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

7. Solaris

False Memory usage alarm!!

Hi Experts, I am using Solaris-10, Sun-Fire-V445. i got often the below message- "Memory Usage – Critical, Memory usage (RAM) exceeding 90% The memory utilization is exceeding 90%" in a application running on solaris. I checked with Vmstat. Everything seems to be fine. Where i should... (5 Replies)
Discussion started by: thepurple
5 Replies

8. Programming

alarm signal processing

I'm writing a function right now, and I want to set an alarm to avoid a timeout, here's the general idea of my code: int amt = -2; alarm(10); amt = read(fd, &t->buf, TASKBUFSIZ - tailpos); //do a read when the alarm goes off, i want to check the value of "amt" ... (1 Reply)
Discussion started by: liaobert
1 Replies

9. Shell Programming and Scripting

basic computer usage report

Our small company, about 5 users, need a basic script that scans mapped network drives (example: drive b,c,d, e, and f) for hard drive usage. This needs to send a report to myself in any type of basic notepad format (easy to read and decipher) for drives that have reached 80% usage... any ideas? ... (1 Reply)
Discussion started by: jessessays
1 Replies

10. UNIX for Dummies Questions & Answers

Basic sed usage in shell script

Hi, A basic sed question. I have a set of files. In each file there is a number that I want replaced. For example, if I run sed I should get the following: % cat test2.txt #goofy//171.00 goofy 171.00 % sed -i 's/171/xxx/g' test2.txt % cat test2.txt #goofy//xxx.00 goofy xxx.00 ... (2 Replies)
Discussion started by: pc2001
2 Replies
FPU_KERN(9)						   BSD Kernel Developer's Manual					       FPU_KERN(9)

NAME
fpu_kern -- facility to use the FPU in the kernel SYNOPSIS
struct fpu_kern_ctx * fpu_kern_alloc_ctx(u_int flags); void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags); int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); int fpu_kern_thread(u_int flags); int is_fpu_kern_thread(u_int flags); DESCRIPTION
The fpu_kern family of functions allows the use of FPU hardware in kernel code. Modern FPUs are not limited to providing hardware implemen- tation for floating point arithmetic; they offer advanced accelerators for cryptography and other computational-intensive algorithms. These facilities share registers with the FPU hardware. Typical kernel code does not need access to the FPU. Saving a large register file on each entry to the kernel would waste time. When kernel code uses the FPU, the current FPU state must be saved to avoid corrupting the user-mode state, and vice versa. The management of the save and restore is automatic. The processor catches accesses to the FPU registers when the non-current context tries to access them. Explicit calls are required for the allocation of the save area and the notification of the start and end of the code using the FPU. The fpu_kern_alloc_ctx() function allocates the memory used by fpu_kern to track the use of the FPU hardware state and the related software state. The fpu_kern_alloc_ctx() function requires the flags argument, which currently accepts the following flags: FPU_KERN_NOWAIT Do not wait for the available memory if the request could not be satisfied without sleep. 0 No special handling is required. The function returns the allocated context area, or NULL if the allocation failed. The fpu_kern_free_ctx() function frees the context previously allocated by fpu_kern_alloc_ctx(). The fpu_kern_enter() function designates the start of the region of kernel code where the use of the FPU is allowed. Its arguments are: td Currently must be curthread. ctx The context save area previously allocated by fpu_kern_alloc_ctx() and not currently in use by another call to fpu_kern_enter(). flags This argument currently accepts the following flags: FPU_KERN_NORMAL Indicates that the caller intends to access the full FPU state. Must be specified currently. FPU_KERN_KTHR Indicates that no saving of the current FPU state should be performed, if the thread called fpu_kern_thread(9) function. This is intended to minimize code duplication in callers which could be used from both kernel thread and syscall contexts. The fpu_kern_leave() function correctly handles such con- texts. The function does not sleep or block. It could cause the Device Not Available exception during execution, and on the first FPU access after the function returns, as well as after each context switch (see Intel Software Developer Manual for the reference). Currently, no errors are defined which can be returned by fpu_kern_enter() to the caller. The fpu_kern_leave() function ends the region started by fpu_kern_enter(). The uses of FPU in the kernel after the call to fpu_kern_leave() are erronous until the next call to fpu_kern_enter() is performed. The function takes the td thread argument, which currently must be curthread, and the ctx context pointer, previously passed to fpu_kern_enter(). After the function returns, the context may be freed or reused by other invocation of fpu_kern_enter(). There are no errors defined for the function, it always returns 0. The fpu_kern_thread() function enables an optimization for threads which never leave to the usermode. The current thread will reuse the usermode save area for the kernel FPU state instead of requiring an explicitly allocated context. There are no flags defined for the func- tion, and no error states that the function returns. Once this function has been called, neither fpu_kern_enter() nor fpu_kern_leave() is required to be called and the fpu is available for use in the calling thread. The is_fpu_kern_thread() function returns the boolean indicating whether the current thread entered the mode enabled by fpu_kern_thread(). There is currently no flags defined for the function, the return value is true if the current thread have the permanent FPU save area, and false otherwise. NOTES
The fpu_kern is currently implemented only for the i386 and amd64 architectures. There is no way to handle floating point exceptions raised from kernel mode. The unused flags arguments to the fpu_kern functions are to be extended to allow specification of the set of the FPU hardware state used by the code region. This would allow optimizations of saving and restoring the state. AUTHORS
The fpu_kern facitily and this manual page were written by Konstantin Belousov <kib@FreeBSD.org>. BSD
October 23, 2014 BSD
All times are GMT -4. The time now is 06:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy