MC-Basic:SEMAPHORETAKE/zh-hans

From SoftMC-Wiki
< MC-Basic:SEMAPHORETAKE
Revision as of 03:14, 28 April 2017 by Chi (talk | contribs) (Created page with "{{Languages}} == 缩写 == semTake == 格式 == <''lval''> = SemTake(<''semaphore name''> { , ''<timeout>''}) == 适用版本 == 从版本3.7.x起 == 描述 == SEMTAKE需...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
语言: [[::MC-Basic:SEMAPHORETAKE|English]]  • [[::MC-Basic:SEMAPHORETAKE/zh-hans|中文(简体)‎]]

缩写

semTake

格式

<lval> = SemTake(<semaphore name> { , <timeout>})

适用版本

从版本3.7.x起

描述

SEMTAKE需要一个可以被多任务同步使用的信号量。如果该信号量是自由状态,SEMTAKE会返回1,改信号量会被标记为“taken”。如果该信号量已经被获取,SEMTAKE会返回0,该信号量的状态不会改变。SEMTAKE可以被用在块联动以访问已经在系统中被共享的资源,或者关键的用户软件部分。

类型

Long

取值范围

return value:          0 = unsuccessful (semaphore not taken)

1 = succeessful (semaphore taken)

<timeout>:             0 to 5000


单位

milliseconds

默认值

0

使用范围

任务区, 终端

限制

例子

While semTake(SEM1,1000) = 0                ‘wait for the release of the semaphore
’wait for resource   

End While

REM critical section code

……

……

semTake(SEM1)                                         ‘take the semaphore

semTake(SEM1 , 100 )

参见