We have two ears and one mouth so that we can listen twice as much as we speak.
Ok - so now we know the target. And unfortunately I have to say, I would also try to iterate over the ports (but rather with one vi than two - maybe there's another reason for that). But unless there is no "port in use" error this is quite difficult.
I intend to use a global array to record serial port name in used
I think we still require more information about what you intend to do.
How do you intend to carry out the iteration? Will you do this by calling each port in turn, and then use the error received as a way of verifying the port is in use.
I thought VISA has a built in semaphor lock, when you open a VISA session a lock is aquired for the resource (ie COM1) and if another session tries to use this resource an error will occur. Visa will manage your resources for you to prevent conflicts.