Patent attributes
A method and system for allowing a single resource (e.g., a serial port) to be shared by multiple applications in a cooperative manner. The first application to use the resource defines a yield callback that is invoked when a second application makes a request for the serial port. The callback allows the first application to decide whether or not it will yield the resource to the second application. If the first application grants the request, the second application is allowed to use the resource; otherwise, the first application continues to use the resource and the second application receives an error message. The first application can be notified when the second application is finished with the resource, so that the resource can be returned to the first application for use.