shù > xìn hào liàng cāo zuò
  yìng yòng chéng chuàng jiàn xìn hào liàng yào diào yòng semget(2)。 tǒng zhōng měi xìn hào liàng yóu semds_id shù jié gòu miáo shù zhōng bāo kuò xià yuán
  structsemid_ds{
  structipc_permsem_perm;/*operationpermissionstruct*/
  structsem*sem_base;/*ptrtofirstsemaphoreinset*/
  ushort_tsem_nsems;/*#ofsemaphoresinset*/
  #ifdefined(_lp64)
  time_tsem_otime;/*lastsemoptime*/
  time_tsem_ctime;/*lastchangetime*/
  #else/*_lp64*/
  time_tsem_otime;/*lastsemoptime*/
  int32_tsem_pad1;/*reservedfortime_texpansion*/
  time_tsem_ctime;/*lastchangetime*/
  int32_tsem_pad2;/*time_texpansion*/
  #endif/*_lp64*/
  intsem_binary;/*flagindicatingsemaphoretype*/
  longsem_pad3;/*reservearea*/
  };
   tǒng huì duì chuán gěi semget(2) de guān jiàn de zhí jìn xíng jiǎn chá lái chá kàn zhè xìn hào liàng shì fǒu jīng cún zài liǎobìng tōng guò shǐ yòng ipc zhī chí chéng ipcaccess() jìn xíng quán xiàn jiǎn cháxìn hào liàng de quán xiàn men zài solaris wén jiàn zhōng shǐ yòng de quán xiàn shì yòu diǎn tóngzhè xiē quán xiàn bèi dìng chéng read alter, zhè yàng jìn chéng jiù dāng qián xìn hào liàng de zhí huò zhě duì gāi zhí jìn xíng xiū gǎizēng / jiǎn xiǎo)。 zhè liǎng quán xiàn shì tōng guò chuán gěi semget(2) diào yòng de cān shù lái jiàn de shǐ yòng solaris wén jiàn quán xiàn zhōng tōng yòng de shǔ zhù yòng de gài niàn
   jiǎ shè yòu xīn de xìn hào liànggēn jǐn jiē de xià cāo zuò jiù shì duì xìn hào liàng zhí jìn xíng chū shǐ huàchū shǐ huà cāo zuò shǐ yòng semctl(2) diào yòng lái shí xiàn shǐ yòng setval lái shè zhì mǒu shí jiān diǎn shàng zhè zhōng měi xìn hào liàng de zhíhuò zhě zhè zhōng zhǐ yòng xìn hào liàng me jiù shè zhì zhè xìn hào liàng de zhí), huò zhě shǐ yòng setall lái shè zhì cāo zuò zhōng gāi zhōng suǒ yòu xìn hào liàng de zhínèi de shí liú chéng shì míng què de shǐ yòng wàng de quán xiàn zhí duì néng de zuì zhí jìn xíng jiǎn chá guǒ suǒ yòu de jiǎn chá tōng guò liǎo me jiǔ shè zhì yòng dìng de zhí
   yìng yòng chéng dài duì xìn hào liàng de shí shǐ yòng huì diào yòng semop(2) tǒng diào yòng。 semop(2) diào yòng shǐ yòng xìn hào liàng de id( yóu semget(2) fǎn huí)、 zhǐ xiàng sembuf jié gòu de zhǐ zhēn xìn hào liàng cāo zuò de shù zuò wéi cān shù。 sembuf jié gòu bāo hán xià yuán
  structsembuf{
  ushort_tsem_num;/*semaphore#*/
  shortsem_op;/*semaphoreoperation*/
  shortsem_flg;/*operationflags*/
  };
   chéng yuán chuàng jiàn sembuf jié gòu bìng duì jìn xíng chū shǐ huàshè zhì semaphore biān hàoshuō míng shì zhōng de xìn hào liàng)、 cāo zuò biāo zhì。 sem_op de zhí jué dìng liǎo xìn hào liàng cāo zuò shì duì xìn hào liàng jìn xíng xiū gǎi hái shì zhè xìn hào liàng de zhífēi 0 de sem_op zhí zēng xìn hào liàng de zhí jiǎn xiǎo xìn hào liàng de zhízhí wéi 0 de sem_op zhǐ shì jiǎn dān de xìn hào liàng de zhí