<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} .ms-cui-menu {background-color:#ffffff;border:1px rgb(166, 166, 166) solid;font-family:'Segoe UI','Segoe WP','Segoe UI WPC',Tahoma,Arial,sans-serif;font-size:10pt;color:rgb(51, 51, 51);} .ms-cui-menusection-title {display:none;} .ms-cui-ctl {vertical-align:text-top;text-decoration:none;color:rgb(51, 51, 51);} .ms-cui-ctl-on {background-color:rgb(228, 238, 230);opacity: 0.8;} .ms-cui-img-cont-float {display:inline-block;margin-top:2px} .ms-cui-smenu-inner {padding-top:0px;} .ms-owa-paste-option-icon {margin: 0px 6px 0px 6px;vertical-align:middle!important;padding-bottom: 2px;display:inline-block;} .ms-rtePasteFlyout-option:hover {background-color:rgb(228, 238, 230) !important;opacity:1 !important;} .ms-rtePasteFlyout-option {padding:8px 4px 8px 4px;outline:none;} .ms-cui-menusection {float:left; width:85px;height:24px;overflow:hidden}.wf {speak:none; font-weight:normal; font-variant:normal; text-transform:none; -webkit-font-smoothing:antialiased; vertical-align:middle; display:inline-block;}.wf-family-owa {font-family:'o365Icons'}@font-face { font-family:'o365IconsIE8'; src:url('prem/15.0.995.34/resources/styles/office365icons.ie8.eot?#iefix') format('embedded-opentype'), url('prem/15.0.995.34/resources/styles/office365icons.ie8.woff') format('woff'), url('prem/15.0.995.34/resources/styles/office365icons.ie8.ttf') format('truetype'); font-weight:normal; font-style:normal;}@font-face { font-family:'o365IconsMouse'; src:url('prem/15.0.995.34/resources/styles/office365icons.mouse.eot?#iefix') format('embedded-opentype'), url('prem/15.0.995.34/resources/styles/office365icons.mouse.woff') format('woff'), url('prem/15.0.995.34/resources/styles/office365icons.mouse.ttf') format('truetype'); font-weight:normal; font-style:normal;}.wf-family-owa {font-family:'o365IconsMouse'}.ie8 .wf-family-owa {font-family:'o365IconsIE8'}.ie8 .wf-owa-play-large:before {content:'\e254';}.notIE8 .wf-owa-play-large:before {content:'\e054';}.ie8 .wf-owa-play-large {color:#FFFFFF/*$WFWhiteColor*/;}.notIE8 .wf-owa-play-large {border-color:#FFFFFF/*$WFWhiteColor*/; width:1.4em; height:1.4em; border-width:.1em; border-style:solid; border-radius:.8em; text-align:center; box-sizing:border-box; -moz-box-sizing:border-box; padding:0.1em; color:#FFFFFF/*$WFWhiteColor*/;}.ie8 .wf-size-play-large {width:40px; height:40px; font-size:30px}.notIE8 .wf-size-play-large {width:40px; height:40px; font-size:30px}.notIE8 .wf-owa-triangle-down-small:before {content:'\e052';}.ie8 .wf-owa-triangle-down-small:before { content:'\e052';}.ie8 .wf-owa-triangle-down-small {color:#666666/*$WFGreyColor*/;}.wf-size-x20 {font-size: 20px!important;}
<!--
p
{margin-top:0;
margin-bottom:0}
.ms-cui-menu
{background-color:#ffffff;
border:1px rgb(166,166,166) solid;
font-family:'Segoe UI','Segoe WP','Segoe UI WPC',Tahoma,Arial,sans-serif;
font-size:10pt;
color:rgb(51,51,51)}
.ms-cui-menusection-title
{}
.ms-cui-ctl
{vertical-align:text-top;
text-decoration:none;
color:rgb(51,51,51)}
.ms-cui-ctl-on
{background-color:rgb(228,238,230)}
.ms-cui-img-cont-float
{display:inline-block;
margin-top:2px}
.ms-cui-smenu-inner
{padding-top:0px}
.ms-owa-paste-option-icon
{margin:0px 6px 0px 6px;
vertical-align:middle!important;
padding-bottom:2px;
display:inline-block}
.ms-rtePasteFlyout-option
{padding:8px 4px 8px 4px;
outline:none}
.ms-cui-menusection
{float:left;
width:85px;
height:24px;
overflow:hidden}
.wf
{speak:none;
font-weight:normal;
font-variant:normal;
text-transform:none;
vertical-align:middle;
display:inline-block}
.wf-family-owa
{font-family:'o365Icons'}
@font-face
{font-family:'o365IconsIE8';
font-weight:normal;
font-style:normal}
@font-face
{font-family:'o365IconsMouse';
font-weight:normal;
font-style:normal}
.wf-family-owa
{font-family:'o365IconsMouse'}
.ie8 .wf-family-owa
{font-family:'o365IconsIE8'}
.notIE8 .wf-owa-play-large
{border-color:#FFFFFF;
width:1.4em;
height:1.4em;
border-width:.1em;
border-style:solid;
text-align:center;
padding:0.1em;
color:#FFFFFF}
.ie8 .wf-size-play-large
{width:40px;
height:40px;
font-size:30px}
.notIE8 .wf-size-play-large
{width:40px;
height:40px;
font-size:30px}
.wf-size-x20
{font-size:20px!important}
-->
--></style>
</head>
<body style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<p class="">We have a question about how the RTEMS binary semaphore behaves when attempting to take the semaphore twice within the same task context.</p>
<p class=""><br class="">
</p>
<p class="">1. To create the semaphore, we run:<br class="">
</p>
<p class=""><br class="">
</p>
<p class=""> rtems_semaphore_create(<br class="">
rtems_build_name('M','U','T','\0') + _al_bsem_mutex_cnt,<br class="">
1, /* FULL - since we are using this for mutual-exclusion */<br class="">
RTEMS_BINARY_SEMAPHORE |<br class="">
RTEMS_PRIORITY |<br class="">
RTEMS_LOCAL |<br class="">
RTEMS_INHERIT_PRIORITY,<br class="">
0, <br class="">
sem_p);</p>
<p class=""><br class="">
</p>
<p class="">2. We then attempt to take it once, and it succeeds. We use:<br class="">
</p>
<p class=""><br class="">
</p>
<p class=""> rtems_semaphore_obtain(<br class="">
*sem_p,<br class="">
RTEMS_WAIT,<br class="">
_Timespec_To_ticks(to));</p>
<p class=""><br class="">
</p>
<p class="">3. We then take it again (from the same task context), and it succeeds. Again, we use:</p>
<p class=""><br class="">
</p>
<p class=""> rtems_semaphore_obtain(<br class="">
*sem_p,<br class="">
RTEMS_WAIT,<br class="">
_Timespec_To_ticks(to));</p>
<p class=""> </p>
<p class="">We did not expect that (3) would succeed. If we attempt step (3), except from another task context, it fails (as expected).</p>
<p class=""><br class="">
</p>
<p class="">Is it expected that (3) should succeed, given it is running in the same task context? The documentation does not appear to say, but perhaps we are missing something?</p>
</body>
</html>