The MCP's Semaphores
The MCP uses semaphores for two different purposes:
Synchronising events such as data collection
Controlling access to resources
Semaphores used to control access to the hardware (MEI, PLC, etc.)
semMEI
Mediate access to the MEI board itself.
- Mutex semaphore
- Created SEM_Q_PRIORITY|SEM_INVERSION_SAFE in axisMotionInit()
- Taken in axisMotionInit() during initialisation
- Taken/given after semMEIDC is taken in mei_data_collection()
- Taken/given in init_cmd(), mcp_move_va(), mcp_set_vel(), mcp_hold(),
mcp_stop_axis(), tBrakes(), slc500_data_collection(), tLatch(),
DIO316ClearISR_delay(), tm_move_instchange(), tm_start_move(),
tm_print_coeffs(), tm_set_filter_coeff(), tm_get_position(),
tm_get_velocity(), tm_reset_integrator(), tm_set_position(),
tm_adjust_position(), tm_sem_controller_run(), tm_sem_controller_idle(),
tm_axis_status(), tm_print_axis_status(), tm_axis_state(),
tm_print_axis_state(), tm_print_axis_source(), tm_show_axis()
- Taken/Given in PVT code: start_frame(), load_frames(), stop_frame(),
stp_frame(), drift_frame(), end_frame(), tm_frames_to_execute(), tm_TCC(),
mcp_drift()
- Taken/Given in unused code:
tm_bf(), tm_set_encoder(), tm_set_analog_encoder(), tm_set_analog_channel(),
tm_set_boot_filter()
- Used in old menu's Menu() and PrintMenuPos() routines
semSLC
Mediate access to the PLC
- Mutex semaphore
- Created SEM_Q_PRIORITY|SEM_INVERSION_SAFE in axisMotionInit()
- Taken/Given in tBrakes(), slc500_data_collection(), tAlgnClmp(),
tSpecDoor(), tm_slithead(), tm_slit_status(), set_mcp_ffs_bits(), tLamps(),
tBars()
semMoveCWBusy
Mediate access to the counter weights
- Binary semaphore
- Created SEM_Q_PRIORITY, SEM_FULL in tMoveCWInit()
- Deleted by tMoveCWFini()
- Taken by tMoveCW() when counterweights are active; given on completion
- Used by mcp_cw_abort(), mcp_set_cw() to see if counterweights are active
semLatch
Mediate access to the fiducials (`latches' to the MEI)
- Binary semaphore
- Created SEM_Q_FIFO, SEM_FULL in tLatchInit()
- Taken/Given by init_cmd(), tLatch(), correct_cmd()
- Used to be used in set_ms_off()
Semaphores used to handle Data Collection
- semDC
-
Used to trigger data collection
- Binary semaphore
- Created SEM_Q_FIFO, SEM_EMPTY in tLatchInit()
- Given by serverDCStart() which is called from timer routine
- Waited for forever by serverData(), waiting to call
data_routine == DataCollectionTrigger()
- semMEIDC
-
Used to trigger collection of MEI data
- Binary Semaphore
- Created SEM_Q_FIFO, SEM_EMPTY in mei_data_collection()
- Infinite loop in mei_data_collection() waits to take it, then
proceeds with data collection from MEI and amplifiers
- Is given by DataCollectionTrigger() just before copying the
contents of sdssdc to shared memory, thus allowing mei_data_collection()
to collect data.
- semSLCDC
-
Used to trigger collection of SLC data
- Binary semaphore
- Created SEM_Q_FIFO, SEM_EMPTY by slc500_data_collection()
- Infinite loop in slc500_data_collection() waits on it
- Is given by DataCollectionTrigger() just before copying the
contents of sdssdc to shared memory, thus allowing slc500_data_collection()
to collect data.
- semSDSSDC
-
Used to control access to struct sdssdc
- Mutex semaphore
- Created SEM_Q_PRIORITY|SEM_INVERSION_SAFE in mei_data_collection()
- Taken/given in DataCollectionTrigger() to write shared memory
- Taken/given in cw_data_collection(), mei_data_collection(),
slc500_data_collection(), il_data_collection()
- Taken/given by PVT code in mcp_move(), mcp_plus_move()
- semMEIUPD
-
- Mutex semaphore
- Created SEM_Q_PRIORITY|SEM_INVERSION_SAFE in mei_data_collection()
- Taken/given in status_cmd(), axis_status_cmd(), system_status_cmd(),
cwstatus_cmd() while accumulating information to return to requester
- Taken/Given by init_cmd(), maybe_reset_axis_pos(), correct_cmd()
to control access to axis_stat[]
- Used in old menu's Menu(), PrintMenuPos(), GetString()
Semaphores used to control access to the MCP
These control access by external processes (TCC, Menu) to the MCP
and ensure that no more than one command is active at a time.
- semCMD
-
- Mutex semaphore
- Created SEM_Q_FIFO in cmdInit()
- Taken/Given by cmd_handler()
- semCmdPort
-
- Mutex semaphore
- Created SEM_Q_PRIORITY|SEM_INVERSION_SAFE in cmdPortServer()
- Controls permission to use restricted commands in cmd_handler()
- Used to set axis_stat[].semCmdPort_taken in slc500_data_collection()
- Given up if held by cpsWorkTask() in response to SEM.GIVE
- GiveForced by cpsWorkTask() in response to SEM.GIVE 1
- Taken in response to SEM.TAKE/SEM.STEAL command in cpsWorkTask()
- Taken by TCC during INIT
- Given by TCC with MOVE command (n.b. no arguments)
- Used to set the axis_stat[].semCmdPort_taken bit if not owned by TCC
Controlling Access to Data Structures
The main shared data structures are:
- The sdssdc struct (== tmaxis)
-
Modified in:
- vers, type
- unmodified
- ctime, sdsstime, axis[] == tmaxis[]
- mei_data_collection(), protected by semSDSSDC
- axis[] == tmaxis[], axis_state[]
- mei_data_collection(), protected by semMEI and semSDSSDC
- inst.pos, inst.strain_gage
- il_data_collection(), protected by semSDSSDC
- weight[].pos
- cw_data_collection(), protected by semSDSSDC
- status, b10
- slc500_data_collection(), protected by semSLC and semSDSSDC
- tccmove[]
- mcp_move(), protected by semSDSSDC
- tccpmove[]
- mcp_plus_move(), protected by semSDSSDC
- pvt[]
- load_frames(), protected by semSDSSDC
- The MEI
-
- the PLC
-