在设备驱动程序中使用stdlib.h [英] Using stdlib.h within a device driver

查看:115
本文介绍了在设备驱动程序中使用stdlib.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写设备驱动程序,并且需要在驱动程序中使用system()函数.要使用system(),我们需要包含<stdlib.h>,该文件似乎在驱动程序中起作用.

I am trying to write a device driver and I need to use system() function in the driver. To use system() we need to include <stdlib.h>, which dosnt seem to work from a driver.

它说找不到这样的文件或目录.

It says no such file or directory found.

设备驱动程序是否有stdlib.h的替代品?还是system()的替代品?

Is there an alternative to stdlib.h for device drivers? Or an alternative to system()?

推荐答案

stdlib.h是用户空间标头.

stdlib.h is a user space header.

用户空间是在其中运行用户进程(即,除内核之外的所有事物)的那组内存位置.进程是程序的执行实例.内核的作用之一是管理该空间内的各个用户进程,并防止它们相互干扰.

User space is that set of memory locations in which user processes (i.e., everything other than the kernel) run. A process is an executing instance of a program. One of the roles of the kernel is to manage individual user processes within this space and to prevent them from interfering with each other.

只有通过使用系统调用,用户进程才能访问内核空间.系统调用是类活动的进程在类Unix操作系统中对内核执行的服务(例如输入/输出(I/O)或进程创建)的请求.活动进程是CPU中当前正在执行的进程,与等待CPU中下一轮的进程相反. I/O是将数据与CPU以及与外围设备(例如磁盘驱动器,键盘,鼠标和打印机)进行数据传输的任何程序,操作或设备.

Kernel space can be accessed by user processes only through the use of system calls. System calls are requests in a Unix-like operating system by an active process for a service performed by the kernel, such as input/output (I/O) or process creation. An active process is a process that is currently progressing in the CPU, as contrasted with a process that is waiting for its next turn in the CPU. I/O is any program, operation or device that transfers data to or from a CPU and to or from a peripheral device (such as disk drives, keyboards, mice and printers).

请检查KERNEL DIRECTORY/include文件夹,以了解可以在内核空间中使用哪些头.

Please check KERNEL DIRECTORY/include folder for what headers can be used in kernel space.

没有其他替代系统命令.

There is no alternative to system command.

可能的解决方案是,您可以从内核空间创建sys/proc条目来设置标志,而从用户空间中可以检查标志并使用system().

Once possible solution is that you can create a sys /proc entry from the kernel space to set a flag, from the user space you can check the flag and use system().

这篇关于在设备驱动程序中使用stdlib.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆