Click here to Skip to main content
15,895,922 members
Home / Discussions / System Admin
   

System Admin

 
GeneralRe: Password store In Windows... Pin
Jumba18-Apr-05 1:05
Jumba18-Apr-05 1:05 
GeneralRe: Password store In Windows... Pin
Ted Ferenc19-Apr-05 0:24
Ted Ferenc19-Apr-05 0:24 
GeneralRe: Password store In Windows... Pin
Mekong River19-Apr-05 23:34
Mekong River19-Apr-05 23:34 
GeneralRe: Password store In Windows... Pin
Ted Ferenc20-Apr-05 0:23
Ted Ferenc20-Apr-05 0:23 
GeneralRe: Password store In Windows... Pin
Mekong River20-Apr-05 12:12
Mekong River20-Apr-05 12:12 
GeneralRe: Password store In Windows... Pin
Steven Campbell19-Apr-05 7:04
Steven Campbell19-Apr-05 7:04 
GeneralWave in and Wave Out device Pin
Member 188219714-Apr-05 3:20
Member 188219714-Apr-05 3:20 
Generalsyncronizing shared memory using semophore Pin
project_unix12-Apr-05 12:00
sussproject_unix12-Apr-05 12:00 
hello programers,

i need your help , i m trying to do this but i m unable to do it ...here we have a code which has two fork()(creating two child)...where one does addition and other subtraction , but if you see output logically should be 0 but it does not , now challange is how to syncronix\ze it using only SEMOPHORES to syncronize it , and get the output 0 all the time

Good luck ...and i would appreciate if youw ill be able to help me :-


// example to show mutual exclusion problem
#include <stdio.h>
#include <sys types.h="">
#include <sys ipc.h="">
#include <sys shm.h="">
#include <string.h>

#define KEY 999030008 // must be unique


void adder(int * memptr){
int n, i=0, total=0;
for(i=0; i<20000; i++){
*memptr += 1;
}
exit(0);
}

void substracter(int * memptr){
int n, i=0, total=0;
for(i=0; i<20000; i++){
*memptr -= 1;
}
exit(0);
}

int main(){
int seg_id;
int * mem_ptr;

// create shared memory segment
seg_id = shmget(KEY,sizeof(int),0600|IPC_CREAT);
if (seg_id==-1){
perror("shmget");
exit(1);
}
// attach to it
mem_ptr=shmat(seg_id, NULL,0);
if ( mem_ptr == 0 ){
perror("shmat");
exit(1);
}

// initial to 0
*mem_ptr = 0;

// create two child. One reader; one writer
if( !fork() ) adder(mem_ptr);
if( !fork() ) substracter(mem_ptr);

// wait for two child
wait(NULL);
wait(NULL);

printf("the value now is %d\n", *mem_ptr);

// detach and then destroy shared memory segment
shmdt((void*)mem_ptr);
shmctl(seg_id, IPC_RMID, NULL);
}
GeneralProtect my system from hacking Pin
joy00712-Apr-05 6:50
joy00712-Apr-05 6:50 
GeneralRe: Protect my system from hacking Pin
Steven Campbell12-Apr-05 7:22
Steven Campbell12-Apr-05 7:22 
GeneralRe: Protect my system from hacking Pin
MoustafaS12-Apr-05 17:36
MoustafaS12-Apr-05 17:36 
GeneralRe: Protect my system from hacking Pin
Ray Cassick13-Apr-05 7:52
Ray Cassick13-Apr-05 7:52 
GeneralRe: Protect my system from hacking Pin
Mekong River20-Feb-06 22:08
Mekong River20-Feb-06 22:08 
QuestionHow to identify admin account Pin
Mekong River12-Apr-05 5:37
Mekong River12-Apr-05 5:37 
AnswerRe: How to identify admin account Pin
dratcha18-Apr-05 14:12
dratcha18-Apr-05 14:12 
GeneralRe: How to identify admin account Pin
Mekong River19-Apr-05 23:29
Mekong River19-Apr-05 23:29 
GeneralRe: How to identify admin account Pin
MoustafaS2-May-05 10:08
MoustafaS2-May-05 10:08 
GeneralRe: How to identify admin account Pin
Mekong River2-May-05 11:31
Mekong River2-May-05 11:31 
GeneralRe: How to identify admin account Pin
MoustafaS2-May-05 12:26
MoustafaS2-May-05 12:26 
GeneralRe: How to identify admin account Pin
Mekong River20-Feb-06 22:21
Mekong River20-Feb-06 22:21 
GeneralPatching windows explorer Pin
hairy_hats11-Apr-05 22:42
hairy_hats11-Apr-05 22:42 
GeneralRe: Patching windows explorer Pin
Mekong River12-Apr-05 5:33
Mekong River12-Apr-05 5:33 
QuestionMap a network drive for all users? Pin
Anonymous11-Apr-05 11:19
Anonymous11-Apr-05 11:19 
AnswerRe: Map a network drive for all users? Pin
Mekong River12-Apr-05 5:12
Mekong River12-Apr-05 5:12 
AnswerRe: Map a network drive for all users? Pin
Ray Cassick13-Apr-05 7:54
Ray Cassick13-Apr-05 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.