With robots entering the world of Cyber Physical Systems (CPS), ordering the execution of allocated tasks during runtime becomes crucial. This is so because, in the real world, there can be several physical tasks that use shared resources that need to be executed concurrently. In this article, we propose a mechanism to solve this issue of ordering task executions within a CPS that inherently handles mutual exclusion. The mechanism caters to a decentralized and distributed CPS comprising nodes such as computers, robots, and sensor nodes and uses mobile software agents that knit through them to aid the execution of the various tasks while also ensuring mutual exclusion of shared resources. The computations, communications, and control are achieved through these mobile agents. Physical execution of the tasks is performed by the robots in an asynchronous and pipelined manner without the use of a clock. The mechanism also features addition and deletion of tasks and insertion and removal of robots facilitating On-The-Fly Programming. As an application, a Warehouse Management System as a CPS has been implemented. The article concludes with the results and discussions on using the mechanism in both emulated and real-world environments.