SEM(4) BSD Kernel Interfaces Manual SEM(4)NAME
sem -- POSIX semaphores
SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file:
options P1003_1B_SEMAPHORES
Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):
sem_load="YES"
kldload sem
DESCRIPTION
The sem facility provides system calls used by the standard C library (libc) to implement POSIX semaphores. This facility offers support for
such functions as sem_init() and sem_wait(). It is available both as a kernel option for static inclusion and as a dynamic kernel module.
SEE ALSO sem_destroy(3), sem_getvalue(3), sem_init(3), sem_open(3), sem_post(3), sem_wait(3), config(8), kldload(8), kldunload(8)HISTORY
The sem facility appeared as a kernel option in FreeBSD 3.0. The sem kernel module appeared in FreeBSD 5.0.
BSD November 11, 2006 BSD
Check Out this Related Man Page
sem_init(3C) Standard C Library Functions sem_init(3C)NAME
sem_init - initialize an unnamed semaphore
SYNOPSIS
#include <semaphore.h>
int sem_init(sem_t *sem, int pshared, unsigned int value);
DESCRIPTION
The sem_init() function is used to initialize the unnamed semaphore referred to by sem. The value of the initialized semaphore is value.
Following a successful call to sem_init(), the semaphore may be used in subsequent calls to sem_wait(3C), sem_trywait(3C), sem_post(3C),
and sem_destroy(3C). This semaphore remains usable until the semaphore is destroyed.
If the pshared argument has a non-zero value, then the semaphore is shared between processes; in this case, any process that can access the
semaphore sem can use sem for performing sem_wait(3C), sem_trywait(3C), sem_post(3C), and sem_destroy(3C) operations.
Only sem itself may be used for performing synchronization. The result of referring to copies of sem in calls to sem_wait(3C), sem_try-
wait(3C), sem_post(3C), and sem_destroy(3C), is undefined.
If the pshared argument is zero, then the semaphore is shared between threads of the process; any thread in this process can use sem for
performing sem_wait(3C), sem_trywait(3C), sem_post(3C), and sem_destroy(3C) operations. The use of the semaphore by threads other than
those created in the same process is undefined.
Attempting to initialize an already initialized semaphore results in undefined behavior.
RETURN VALUES
Upon successful completion, the function initializes the semaphore in sem. Otherwise, it returns -1 and sets errno to indicate the error.
ERRORS
The sem_init() function will fail if:
EINVAL The value argument exceeds SEM_VALUE_MAX.
ENOSPC A resource required to initialize the semaphore has been exhausted, or the resources have reached the limit on semaphores
(SEM_NSEMS_MAX).
ENOSYS The sem_init() function is not supported by the system.
EPERM The process lacks the appropriate privileges to initialize the semaphore.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
|ATTRIBUTE TYPE |ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
|Standard |See standards(5). |
+-----------------------------+-----------------------------+
SEE ALSO sem_destroy(3C), sem_post(3C), sem_wait(3C), attributes(5), standards(5)SunOS 5.11 5 Feb 2008 sem_init(3C)
i really have an issue with the otherwise outstading FreeBSD Handbook when it comes to kernel building. information on the proper steps to take is really confusing. i think that chapters 9 and 21 need to be combined to give a very concise format on how best to deal with kernel building/rebuidling... (1 Reply)
Hey guys, I have installed Freebsd 5.3 Release, and I can't compile my custom kernel. I even tried compile the Generic kernel to see if I had some error in my custom kernel, and that didn't compile either. The Freebsd FAQ pages states one solution would be to "re-fetch the source tree". How is... (8 Replies)
hi there,
i am porting kernel 2.2 driver program to kernel 2.6. for some extent i am successfull but some times the system gets hanged. what might be the problem? i am not able to get any help from log messages as nothing is being printed at that moment. hey does this kernel preemptiveness and... (2 Replies)
Hi to all,
Iam using FreeBSD 5.4. I want to write a kernel file with an option "CD9660_ROOT" in it. When i start to compile this kernel, it gives a message "unknown option CD9660_ROOT". Could anyone hellp with this as soon as possible.
Bye,
tadakamalla (3 Replies)
Hi,
I would like o implement a kernel call, but I don't know how to do it. Where can I find an example?
I've already look to minix source code, but I'm still confused and not very comfortable to mess with the code at this level.
Thanks, (1 Reply)
All,
I am a bit of a BSD newbie and haven't really played with it for years, but I have had a recent situation whereby someone attempted to load a custom kernel module and ended up breaking my BSD server.
I managed to fix it by doing the following:
Booting into loader mode:
unload
set... (3 Replies)
Hi. I am thinking to create an OS. I don't want to use linux kernel. I want to use BSD Kernel and this also means that because will be on UFS, I cannot use Gparted.
This are my 2 questions.
1) Where can I download BSD Kernel.
2) Witch is the tool to create the partitions. (I think is gpart but I... (1 Reply)
Hi friends,
I am using semaphores in my program, but when I compile the program, it gives the following error
$ gcc sem.c -o sem -lpthread
Undefined first referenced
symbol in file
sem_init ... (1 Reply)
hello,
I was going through clustering documentation for Redhat, it says "Enable IP Aliasing support in the kernel by setting the CONFIG_IP_ALIAS kernel option to y. When specifying kernel options, under Networking Options, select IP aliasing support", I knew I should update /etc/sysctl.conf with... (1 Reply)
I have some files as shown below
GLL ALM 654-656 654 656
SEM LYG 655-657 655 657
SEM LYG 655-657 655 657
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
LEG LEG 658-660 658 660
LEG LEG 658-660 658 660 The value of GLL is... (5 Replies)
Hi,
I am working on kernel parameters, want to check values under /proc/sys/kernel
below I tried for kernel.sem
SEMMNS: 4096 cat /proc/sys/kernel/sem | awk '{print $2}'
awk '{ if ($2 < 33000) print }' /proc/sys/kernel/sem |awk '{print $2}'
32000
The above... (7 Replies)
Hi All,
I am searching for some files (*.sem and *.chk and *.temp) in morethan one directories.
if i found .sem and .chk files(base name should be same) i am deleting these 2 files because i need to delete .chk files if i found respective .sem file
i am also deleting other .sem files only... (6 Replies)
Hello All,
I have some files like file, file.chk, file.sem and file.temp in huge. I would like to delete some files based on following criteria.
1. Unconditionally delete .sem and .temp files
2. If we found the actual file, don't remove .chk file, otherwise remove .chk file as well
for... (5 Replies)