User spaces are a powerful tool in every System i programmer’s toolbox. One interesting way to use them is as a means of communicating between different jobs in the system. Because a pointer can address user spaces, you can use them the same way that you use variables, making passing a large amount of data between jobs easy.
When you program in this manner, you have to be careful that two different jobs aren’t changing the user space at the same time. The Lock Space Location (LOCKSL) MI built-in function provides a means of locking sections of a user space in much the same way that you’d lock records in a database file.
In today’s APIs by Example, I show you how to combine the use of the Space Location MI built-ins and user space APIs to address the problem of concurrent update conflicts.