In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Development platform Lingsi Sinlinx A64
Memory: 1GB storage: 4GB
Detailed parameters of the development board https://m.tb.cn/h.3wMaSKm
Development board communication group 641395230
Blocking: blocking calls means that the current process is suspended (dormant) before the result of the call is returned. The function does not return until the result is obtained. By default, files are opened in this way.
Non-blocking: this function does not block the current process but returns immediately until the result is not immediately available. The application can choose to open the device file in a blocking or non-blocking mode, and then the device reads and writes, which will be different if the read-write function of the driver supports blocking and non-blocking functions.
Blocking example: fd = open ("/ xxx/word", O_RDONLY); / / enabled by default blocking method
If there is no data to read at this time, hibernation is performed
If there is data to read, read the data immediately, do not sleep, and return immediately after reading the data.
Non-blocking example: fd = open ("/ xxx/word", O_RDONLY | O_NONBLOCK); / / Open in non-blocking mode
If there is already data to read at this time, read the data and return.
If there is no data to read, return immediately, but return an error code.
1) how to get the way to open the user space application in the driver?
Open a device, the kernel will create a file structure, and the value of the open mode will be stored in the f_flags member of the file structure. The read,write interface of the driver can use the parameter file pointer to get the file opening mode. One member of the file structure is f_flags, and when created, the kernel stores the flag value of the last parameter of the open function in the f_flags variable.
Static ssize_t xxx_read (struct file * pfile, char user * buf, size_t count, loff_t * poff) {. / / determine whether there is a key action if (no key action) {/ / determine whether the pfile- > f_flags member sets O_NONBLOCK if (pfile- > f_flags & O_NONBLOCK) / / indicates that user space uses non-blocking to open {return-EAGAIN / / return an error code that tells the user space that you can try to read} / / open the blocking mode again, sleep if there is no data, do not immediately return to else {/ / hibernation, and wait for a key action to wake up the process. }}}
2) how do I know if there is a key press?
If you press the key or release time, there will be an interrupt, so set a flag in the interrupt program.
Define a global variable with an initial value of 0, indicating that no keystroke action has occurred. Set this variable to 1 in the interrupt program to indicate that a keystroke action has occurred.
3) how to put the process into hibernation?
The simplest and most direct sleep mode: msleep function
This function: once called, the calling process will sleep for a specified long time, and the kernel will wake up the process when the time is up.
/ / hibernate, waiting for a keystroke to wake up the process.
While (press = = 0) msleep (5); / / dormant 5ms
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.