Sponsored Content
Full Discussion: semclt system call ???
Top Forums Programming semclt system call ??? Post 7042 by abdul on Tuesday 18th of September 2001 06:40:54 AM
Old 09-18-2001
semclt system call ???

hi mates,
What is the : semctl system call for? any example will be helpful and be appreciated.

cya and thanx

abdul
 

10 More Discussions You Might Find Interesting

1. Programming

Problem in system call

Dear Friends, I write a c program to list the directories recursively. For this I write a function called my_readdir to read the content of directory. For this I use read system call it returns -1, then I use readdir system call it gives comment terminated error or segmentation... (1 Reply)
Discussion started by: spmlingam
1 Replies

2. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

3. Programming

c system call

How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies

4. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

5. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

6. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

7. Programming

need help with system call

hi everyone i wrote a system call and compiled the kernel succesfully... my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c) the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h my problem is... (2 Replies)
Discussion started by: demis87
2 Replies

8. Shell Programming and Scripting

system call

Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035> poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies

9. Programming

[C] exec system call

Hi again ;) Now I want to make a program that will execute the programs with exec, asking the user if he wants the program to run in background or foreground. scanf("%c",&caracter); if (caracter=='y'){ printf("Has decidido ejecutarlo en background\n"); if((pid=fork())==0) {// fork para... (3 Replies)
Discussion started by: lamachejo
3 Replies

10. Programming

c programming system call

newPerm = oldPerm & ~0100; where oldPerm holds the value of st_mode from the system call stat(). When I try and compile every line where ive attempted to do these operations gives the warning "parameter names without declaration types in function declaration". what could be the problem? the... (2 Replies)
Discussion started by: bjhum33
2 Replies
SEMCTL(2)						      BSD System Calls Manual							 SEMCTL(2)

NAME
semctl -- semaphore control operations LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/sem.h> int semctl(int semid, int semnum, int cmd, ...); DESCRIPTION
The semctl() system call provides a number of control operations on the semaphore specified by semnum and semid. The operation to be per- formed is specified in cmd (see below). The fourth argument is optional and depends upon the operation requested. If required, it is a union of the following fields: int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */ u_short *array; /* array for GETALL & SETALL */ The semid_ds structure used in the IPC_SET and IPC_STAT commands is defined in <sys/sem.h> and contains the following members: struct ipc_perm sem_perm; /* operation permissions */ unsigned short sem_nsems; /* number of sems in set */ time_t sem_otime; /* last operation time */ time_t sem_ctime; /* last change time */ The ipc_perm structure used inside the semid_ds structure is defined in <sys/ipc.h> and contains the following members: uid_t cuid; /* creator user id */ gid_t cgid; /* creator group id */ uid_t uid; /* user id */ gid_t gid; /* group id */ mode_t mode; /* permission (lower 9 bits) */ semctl() provides the following operations: GETVAL Return the value of the semaphore. SETVAL Set the value of the semaphore to arg.val, where arg is the fourth argument to semctl(). GETPID Return the pid of the last process that did an operation on this semaphore. GETNCNT Return the number of processes waiting to acquire the semaphore. GETZCNT Return the number of processes waiting for the value of the semaphore to reach 0. GETALL Return the values of all the semaphores associated with semid. SETALL Set the values of all the semaphores that are associated with the semaphore identifier semid to the corresponding values in arg.array, where arg is the fourth argument to semctl(). IPC_STAT Gather information about a semaphore and place the information in the structure pointed to by arg.buf, where arg is the fourth argument to semctl(). IPC_SET Set the value of the sem_perm.uid, sem_perm.gid and sem_perm.mode fields in the structure associated with the semaphore. The val- ues are taken from the corresponding fields in the structure pointed to by arg.buf, there arg is the fourth argument to semctl(). This operation can only be executed by the super-user, or a process that has an effective user id equal to either sem_perm.cuid or sem_perm.uid in the data structure associated with the semaphore. IPC_RMID Remove the semaphores associated with semid from the system and destroy the data structures associated with it. Only the super- user or a process with an effective uid equal to the sem_perm.cuid or sem_perm.uid values in the data structure associated with the semaphore can do this. The permission to read or change a semaphore (see semop(2)) is determined by the sem_perm.mode field in the same way as is done with files (see chmod(2)), but the effective uid can match either the sem_perm.cuid field or the sem_perm.uid field, and the effective gid can match either sem_perm.cgid or sem_perm.gid. RETURN VALUES
For the GETVAL, GETPID, GETNCNT, and GETZCNT operations, semctl() returns one of the values described above if successful. All other opera- tions will make semctl() return 0 if no errors occur. Otherwise -1 is returned and errno set to reflect the error. ERRORS
semctl() will fail if: [EACCES] The caller has no operation permission for this semaphore. [EFAULT] arg.buf or arg.array specifies an invalid address. [EINVAL] semid is not a valid message semaphore identifier. cmd is not a valid command. [EPERM] cmd is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does the effective uid match either the sem_perm.uid or sem_perm.cuid fields of the data structure associated with the semaphore. [ERANGE] cmd is equal to SETVAL or SETALL and the value to be set is greater than the system semaphore maximum value. SEE ALSO
semget(2), semop(2) STANDARDS
The semctl system call conforms to X/Open System Interfaces and Headers Issue 5 (``XSH5''). HISTORY
Semaphores appeared in the first release of AT&T System V UNIX. BSD
August 25, 1999 BSD
All times are GMT -4. The time now is 06:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy