Global regularity and stability of solutions to the single and double obstacle problems with nonstandard growth