It might be useful for you to do
man pthread_setschedparam at a command-line.
"Operation not permitted" corresponds to an EPERM error-code, whereas "invalid argument" is EINVAL.
This is a POSIX written-by-committee error message, so you'll have to excuse the pontificating use of the word "shall" in the text of that man-page.