Type-Safe Operating System Abstractions