The way I first read it, by setting off the "mostly written in C" with the commas, you are making it additional or parenthetical information. So the kernel is the subject. And as a singular word, you need the singular verb form, communicates.
But on a second reading, I thought that perhaps routines are supposed to be the things that communicate, not the kernel. (Perhaps your readers would know that? Kernels are things I turn into popcorn.) But as it is, the construction leads to ambiguity.
Try one of these, depending on what the real meaning is:
The kernel comprises a set of routines mostly written in C and communicates with the hardware directly. Here the kernel comprises and communicates.
or
The kernel comprises a set of routines, which are mostly written in C and communicate with the hardware directly. Here the routes are written in C and communite.