1. A multithreaded microcontroller comprising: a set of special-purpose multithreading registers including a set of thread state registers storing a plurality of thread states for a corresponding plurality of threads; thread control logic connected to the set of multithreading registers, comprising: thread state transition logic connected to the set of thread state registers and configured to control thread state transitions for the plurality of threads; and thread instructions execution logic connected to the set of thread state registers and configured to execute a set of multithreading system call machine code instructions; and a hardware thread profiler connected to the set of multithreading registers, the thread profiler comprising thread profiling logic configured to collect thread profiling data for the plurality of threads, the thread profiling data comprising at least one datum selected from a group consisting of a set of state transition counts, an amount of time spent by a thread in a subset of thread states, and a set of thread priority raise counts.