02-18-2009
Quote:
Originally Posted by
ChrisWilliams
Thanks for the reply.
Yes that makes the difference. It works for me now as well.
The strange behaviour is why did it link WOTHOUT the added library?
Its as though there are some dummy functions for when you don't link in the library!
Chris.
The thread functions and data types are declared in pthread.h, but the pthread functions are not included in the standard C library "libc". Instead, they are in a separate library "libpthread", so you should add lpthread to the command line when you link your program.
That's also an issue with trigonometric functions such as sin and cos, they are declared in math.h but the functions are in the library "libm". To compile programs with these functions you have to add -lm to the command line.
Regards
10 More Discussions You Might Find Interesting
1. Programming
Hi all,
I am working in a UNIX/C environment. I would like to understand more about MUTEX and Threads. Can someone explain me these
concepts and how they are related.
Vijay (2 Replies)
Discussion started by: vthasan
2 Replies
2. UNIX for Dummies Questions & Answers
Can anyone explain me what mutexes are in
multithreading environment? (2 Replies)
Discussion started by: sagar
2 Replies
3. Shell Programming and Scripting
A shell in crontab per 5 min write a file
B shell in crontab per 6 min read a file
how to lock the share file a ;avioid confilict in write and read?
Thx : -) (1 Reply)
Discussion started by: zz_xm
1 Replies
4. Programming
Hi, I have two tasks 'Read' and 'Write' which reads and writes on a file "abc.txt" respectively.
Now I need to restrict the Write operation on the file while Read is going on, But can allow two Reads at a time.
ie. two Reads can happen simultaneously, but Write can't happen at Read is going on.
... (3 Replies)
Discussion started by: satheeshalle
3 Replies
5. Programming
Hi,
can someone explain me the difference between mutex and semaphores?
Thanks (1 Reply)
Discussion started by: rvan
1 Replies
6. UNIX for Dummies Questions & Answers
can u tell me what is the exact difference b/w mutex and semaphore
and what is the diff b/w counting semaphore and binary semaphore
amit (1 Reply)
Discussion started by: amitpansuria
1 Replies
7. Shell Programming and Scripting
Hello Everyone,
I just joined this forum and this is my first post.
I would like to know how can I impliment basic read/write locks in perl. I have a database (file) which can be accessed simultaneously but has to be locked while writing.
If there is no such support in perl, my next... (6 Replies)
Discussion started by: superuser84
6 Replies
8. Programming
Hi all,
I have a scenario where I need to use the mutex locks. The mutex locks are working fine, but sometimes I am getting into the dead lock situation.
Below is the summary of my code :
MUTEX LOCK
performTask();
MUTEX UNLOCK.
In some cases I get into the situation where... (2 Replies)
Discussion started by: cjjoy
2 Replies
9. Programming
Hello,
I have got some issue with the struct variable with passed arguments
the variable in the sturct is only recognize the last value their assigned to
I'm pretty confused why the mutex didn't work out
here is my program:
#include<stdio.h>
#include<pthread.h>
pthread_mutex_t lock... (3 Replies)
Discussion started by: michael23
3 Replies
10. Programming
Hi All,
To avoid race condition, instead of using mutex, semaphore, spinlock etc.... Is there any other mechanism by which we can avoid race condition in an multi-threading environment.
-Thanks (6 Replies)
Discussion started by: rvan
6 Replies
INTRO(3) Library Functions Manual INTRO(3)
NAME
intro - introduction to library functions
SYNOPSIS
#include <stdio.h>
#include <math.h>
DESCRIPTION
This section describes functions that may be found in various libraries, other than those functions that directly invoke UNIX system primi-
tives, which are described in section 2. Functions are divided into various libraries distinguished by the section number at the top of
the page:
(3) These functions, together with those of section 2 and those marked (3S), constitute library libc, which is automatically loaded by
the C compiler cc(1) and the Fortran compiler f77(1). The link editor ld(1) searches this library under the `-lc' option. Declara-
tions for some of these functions may be obtained from include files indicated on the appropriate pages.
(3M) These functions constitute the math library, libm. They are automatically loaded as needed by the Fortran compiler f77(1). The link
editor searches this library under the `-lm' option. Declarations for these functions may be obtained from the include file
<math.h>.
(3S) These functions constitute the `standard I/O package', see stdio(3). These functions are in the library libc already mentioned.
Declarations for these functions may be obtained from the include file <stdio.h>.
(3X) Various specialized libraries have not been given distinctive captions. The files in which these libraries are found are named on
the appropriate pages.
FILES
/lib/libc.a
/lib/libm.a, /usr/lib/libm.a (one or the other)
SEE ALSO
stdio(3), nm(1), ld(1), cc(1), f77(1), intro(2)
DIAGNOSTICS
Functions in the math library (3M) may return conventional values when the function is undefined for the given arguments or when the value
is not representable. In these cases the external variable errno (see intro(2)) is set to the value EDOM or ERANGE. The values of EDOM
and ERANGE are defined in the include file <math.h>.
ASSEMBLER
In assembly language these functions may be accessed by simulating the C calling sequence. For example, ecvt(3) might be called this way:
setd
mov $sign,-(sp)
mov $decpt,-(sp)
mov ndigit,-(sp)
movf value,-(sp)
jsr pc,_ecvt
add $14.,sp
INTRO(3)