Is there anything like a hogCPU() function in V5 Pro? So we can force the completion of a portion of a task before task switch?
There is, but it has potentially more serious implications than the version in ROBOTC and is not exposed through any of the C++ classes. What is the problem you are trying to solve ?
Have a multi-motor lift and want to be sure all the motors get set to the same movement without possible task switching interruption.
There will always be some slight difference when sending commands to motors. Motors communicate with the V5 brain every 5mS, commands are sent back to the motor in response to their status messages, so from the time that a motor command is requested by user code there is the possibility for a delay of up to 5mS before that command is sent to the motor.
VEXcode is using a cooperative scheduler and, unlike ROBOTC that could potentially cause a task switch on any line of code due to its use of a VM, we can only task switch when either sleep/yield is called or when one of the vex APIs is used. When a task is allowed to run, it is generally given a 2mS time slot (that’s technically variable but we don’t expose using C++), so if sleep/yield is called before sending commands to several motors you are pretty much guaranteed that they will all be executed without interruption, you can do a lot in 2mS on the V5. Most tasks will call sleep/yield before the 2mS has elapsed if running a typical while loop in the code. The situations where that will not happen generally involve complex graphics or access to slow devices such as the SD card.
So with that information I may be inclined to call yield if I had concerns that there may be a task switch during motor control to a particularly slow task, you should then have a 2mS window to send everything to the motors, but even doing that still has the 5mS issue I described earlier. I’ll send DM with the hog call if you want to try it.