Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ main()
{
for(i=0;i<3;i++)
{
printf("\n Child process is running,pid=%d,ppid=%d",getpid(),getppid());
printf("\n child process is running,pid=%d,ppid=%d",getpid(),getppid());
sleep(2);
}
printf("\n Child Exited\n");
printf("\n child Exited\n");
sleep(2);
}
else if(n>0)
Expand Down
8 changes: 4 additions & 4 deletions semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ main()
if(semctl(sid,0,SETVAL,1)==0)
printf("Semaphore initialized as 1\n");
if((val1 = semctl(sid,0,GETVAL))>0)
printf("Value of semaphore is %d\n",val1);
printf("value of semaphore is %d\n",val1);

if((val = semop(sid,&s[0],1)) == 0)
printf("Semaphore locked\n");
val1=semctl(sid,0,GETVAL);
printf("Value of semaphore after locking id %d\n",val1);
printf("value of semaphore after locking id %d\n",val1);

s[0].sem_op=1;
semop(sid,&s[0],1);
printf("Semaphore unlocked\n");
val1=semctl(sid,0,GETVAL);
printf("Value after unlocking is %d\n",val1);
printf("value after unlocking is %d\n",val1);

if((semctl(sid,0,IPC_RMID) == 0))
printf("Close the semaphore\n");
printf("close the semaphore\n");
}