[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference azur::mcc

Title:DECmcc user notes file. Does not replace IPMT.
Notice:Use IPMT for problems. Newsletter location in note 6187
Moderator:TAEC::BEROUD
Created:Mon Aug 21 1989
Last Modified:Wed Jun 04 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:6497
Total number of notes:27359

2355.0. "Condition variable routines?" by QUIVER::DESMOND () Mon Feb 17 1992 19:40

    Are there any MCC jacket routines for condition variables?  If not, do
    I just use the CMA condition variable routines?
    
    							John
T.RTitleUserPersonal
Name
DateLines
2355.1There are routines .. but they didn't get documented for Field TestMOLAR::ROBERTSKeith Roberts - DECmcc Toolkit TeamTue Feb 18 1992 08:509
  John,

  Yes, there are DECmcc Condition Variable routine wrappers ... but they
  didn't get documented for Field Test.  There is an ULTRIX ECO which will
  add these routines to the SRM.  I will post the draft edition of these
  routines in the next reply -- Hopefully they are correct   8)

  /keith
2355.2Draft copy of DECmcc SRM Condition Variable routinesMOLAR::ROBERTSKeith Roberts - DECmcc Toolkit TeamTue Feb 18 1992 08:54668
  mcc_condition_broadcast





  __________________________________________________________________

  mcc_condition_broadcast-Broadcast on a condition variable

                  Broadcast on a condition variable, unblocking
                  all threads currently waiting on the condition
                  variable.



  __________________________________________________________________

  FORMAT

                  mcc_condition_broadcast  condition



  __________________________________________________________________

  RETURNS

                  MCC Usage:       cond_value

                  data type:       MCC_T_CVR

                  access:          write only

                  mechanism:       by value

                  Condition values that this routine returns are
                  listed under CONDITION VALUES RETURNED


  __________________________________________________________________

  ARGUMENTS
                  CONDITION

                  MCC Usage:      handle

                  data type:      MCC_T_CONDVAR

                  access:         read only

                  mechanism:      by reference

                  Handle of condition variable to be broadcast





  condition-22




                                             mcc_condition_broadcast







  __________________________________________________________________

  DESCRIPTION
                  This routine wakes up all threads waiting on the
                  condition variable.

                  This operation must be called when data guarded by
                  the mutex associated with the condition variable
                  has been changed in such a way the it might be
                  possible for more than one thread waiting on the
                  condition to proceed. For example, this would be
                  used to wake up all readers waiting for shared
                  read access to some data.

                  This routine is not alertable.


  __________________________________________________________________

  CONDITION VALUES RETURNED

                  MCC_S_NORMAL       Normal successful completion

                  MCC_S_EXISTENCE_   Object does not exist
                  ERROR

                  MCC_S_INVOBJTYPE   Invalid type of referenced
                                     object

                  MCC_S_REQARG       Required argument is missing

                  MCC_S_USE_ERROR    Incorrect use of handle

                  MCC_S_             Wrong number of arguments
                  WRONGNUMARGS
















                                                        condition-23




  mcc_condition_create





  __________________________________________________________________

  mcc_condition_create-Create a condition variable

                  This routine creates and initializes a condition
                  variable object and returns its handle.



  __________________________________________________________________

  FORMAT

                  mcc_condition_create  condition



  __________________________________________________________________

  RETURNS

                  MCC Usage:       cond_value

                  data type:       MCC_T_CVR

                  access:          write only

                  mechanism:       by value

                  Condition values that this routine returns are
                  listed under CONDITION VALUES RETURNED


  __________________________________________________________________

  ARGUMENTS
                  CONDITION

                  MCC Usage:      Handle

                  data type:      MCC_T_CONDVAR

                  access:         write only

                  mechanism:      by reference

                  Variable that receives the handle for the new
                  condition-variable.





  condition-24




                                                mcc_condition_create







  __________________________________________________________________

  DESCRIPTION
                  This procedure creates and initializes a condition
                  variable object and returns its handle which may
                  be shared by threads to access the object.

                  Condition variables created by this procedure
                  are not owned by any particular thread and any
                  associated storage is not automatically recleaimed
                  if the creating thread terminates.

                  This routine is not alertable.


  __________________________________________________________________

  CONDITION VALUES RETURNED

                  MCC_S_NORMAL       Normal successful completion

                  MCC_S_EXISTENCE_   Object does not exist
                  ERROR

                  MCC_S_INSVIRMEM    Insufficient virtual memory

                  MCC_S_REQARG       Required argument is missing

                  MCC_S_USE_ERROR    Incorrect use of handle

                  MCC_S_             Wrong number of arguments
                  WRONGNUMARGS



















                                                        condition-25




  mcc_condition_delete





  __________________________________________________________________

  mcc_condition_delete-Delete a condition variable

                  This routine deletes a condition variable



  __________________________________________________________________

  FORMAT

                  mcc_condition_delete  condition



  __________________________________________________________________

  RETURNS

                  MCC Usage:       cond_value

                  data type:       MCC_T_CVR

                  access:          write only

                  mechanism:       by value

                  Condition values that this routine returns are
                  listed under CONDITION VALUES RETURNED


  __________________________________________________________________

  ARGUMENTS
                  CONDITION

                  MCC Usage:      handle

                  data type:      MCC_T_CONDVAR

                  access:         modify

                  mechanism:      by reference

                  Handle for the condition variable that will no
                  longer be referenced.






  condition-26




                                                mcc_condition_delete




  __________________________________________________________________

  DESCRIPTION
                  This operation should be called when a condition
                  variable will no longer be referenced by any
                  threads. The effect of this operation is to give
                  permission to reclaim storage for the condition
                  variable.

                  The condition variable is deleted and the
                  CONDITION parameter is set to the value MCC_K_
                  NULL.

                  Calling this operation with a CONDITION parameter of 
                  MCC_K_NULL is legal and has no effect.

                  If the condition variable currently has waiting
                  threads, then the operation will fail and an
                  error condition code (MCC_S_IN_USE_ERROR) will
                  be returned.

                  If the mutex does not exist, then the operation
                  will fail and an error condition code (MCC_S_
                  EXISTENCE) will be returned.

                  This routine is not alertable.



  __________________________________________________________________

  CONDITION VALUES RETURNED

                  MCC_S_NORMAL       Normal success completion

                  MCC_S_EXISTENCE_   The object does not exist
                  ERROR

                  MCC_S_IN_USE_      The object is currently in use
                  ERROR

                  MCC_S_INVOBJTYPE   Invalid type of referenced
                                     object

                  MCC_S_REQARG       Required argument is missing

                  MCC_S_USE_ERROR    Incorrect use of handle

                  MCC_S_             Wrong number of arguments
                  WRONGNUMARGS




                                                        condition-27




  mcc_condition_signal





  __________________________________________________________________

  mcc_condition_signal-Signal a condition variable

                  Signal a condition variable, unblocking one thread
                  waiting on the condition variable.



  __________________________________________________________________

  FORMAT

                  mcc_condition_signal  condition



  __________________________________________________________________

  RETURNS

                  MCC Usage:       cond_value

                  data type:       MCC_T_CVR

                  access:          write only

                  mechanism:       by value

                  Condition values that this routine returns are
                  listed under CONDITION VALUES RETURNED


  __________________________________________________________________

  ARGUMENTS
                  CONDITION

                  MCC Usage:      handle

                  data type:      MCC_T_CONDVAR

                  access:         read only

                  mechanism:      by reference

                  Handle of condition variable to be signaled






  condition-28




                                                mcc_condition_signal




  __________________________________________________________________

  DESCRIPTION
                  This routine wakes up one thread currently waiting
                  on the condition variable.

                  This operation must be called when data guarded by
                  the mutex associated with the condition variable
                  has been changed in such a way the it might be
                  possible for one thread waiting on the condition
                  to proceed. For example, this would be used to
                  wake up a thread waiting for exclusive access to
                  some data.

                  This operation can be called with the mutex either
                  locked or unlocked.

                  This routine is not alertable.



  __________________________________________________________________

  CONDITION VALUES RETURNED

                  MCC_S_NORMAL       Normal successful completion

                  MCC_S_EXISTENCE_   Object does not exist
                  ERROR

                  MCC_S_INVOBJTYPE   Invalid type of referenced
                                     object

                  MCC_S_REQARG       Required argument is missing

                  MCC_S_USE_ERROR    Incorrect use of handle

                  MCC_S_             Wrong number of arguments
                  WRONGNUMARGS















                                                        condition-29




  mcc_condition_wait





  __________________________________________________________________

  mcc_condition_wait-Wait for condition variable

                  A thread can wait for a condition variable to be
                  signaled or broadcast by calling this procedure.



  __________________________________________________________________

  FORMAT

                  mcc_condition_wait  condition, mutex



  __________________________________________________________________

  RETURNS

                  MCC Usage:       cond_value

                  data type:       MCC_T_CVR

                  access:          write only

                  mechanism:       by value

                  Condition values that this routine returns are
                  listed under CONDITION VALUES RETURNED


  __________________________________________________________________

  ARGUMENTS
                  CONDITION

                  MCC Usage:      handle

                  data type:      MCC_T_CONDVAR

                  access:         read only

                  mechanism:      by reference

                  The condition variable to be waited on.






  condition-30




                                                  mcc_condition_wait





                  mutex

                  MCC Usage:      handle

                  data type:      MCC_T_MUTEX

                  access:         read only

                  mechanism:      by reference

                  Handle of mutex associated with the condition
                  variable.






  __________________________________________________________________

  DESCRIPTION
                  This operation must be called with the mutex
                  locked. This operation automatically releases
                  the mutex and causes the thread to wait on the
                  condition. If the wait is satisfied as a result
                  of some thread calling MCC_CONDITION_BROADCAST or
                  MCC_CONDITION_SIGNAL, then the mutex is reacquired
                  and the procedure returns.

                  This operation might (with low probability) return
                  spuriously without the condition variable being
                  signalled or broadcast. It is recommended that
                  the client retest the predicate condition after
                  returning from this operation.

                  If the operation fails to unlock the mutex, then
                  the operation will fail and the error condition
                  will be returned.

                  If the routine is alerted, then the mutex will be
                  reacquired before returning.


                  This routine is alertable.









                                                        condition-31




  mcc_condition_wait




  __________________________________________________________________

  CONDITION VALUES RETURNED

                  MCC_S_NORMAL       Normal successful completion

                  MCC_S_EXISTENCE_   Object does not exist
                  ERROR

                  MCC_S_IN_USE_      Object is currently in use
                  ERROR

                  MCC_S_INVOBJTYPE   Invalid type of referenced
                                     object

                  MCC_S_REQARG       Required argument is missing

                  MCC_S_USE_ERROR    Incorrect use of handle

                  MCC_S_             Wrong number of arguments
                  WRONGNUMARGS
	

2355.3MCC wrappers are meant to be transitionaryTOOK::BURGESSTue Feb 18 1992 13:4216
The mcc condition variable and mutex routines are layered on DECthreads.
You may choose to use the CMA or POSIX API to the synchronization primitives
or other threading services.


When the POSIX API evolves from a draft to a standard, then
this API will be the prefered interface to multi-threading services.

In the mean time you have 3 sub-optimum API choices:
	o POSIX draft 1003.4a  which might change
	o CMA which won't change but might not be found on
	  as many platforms as the POSIX API
	o MCC wrappers which currently use the CMA interface.


\Pete