Linux API Dr. Michael L. Collard [email protected] 1.
-
Upload
ashlee-ferguson -
Category
Documents
-
view
214 -
download
2
Transcript of Linux API Dr. Michael L. Collard [email protected] 1.
![Page 2: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/2.jpg)
Linux Systems Programming
• Linux API – set of calls that applications, directly or indirectly, use to interact with the Linux kernel
• File, directory, and filesystem access• Communication• Concurrency• Control
![Page 3: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/3.jpg)
Device Interface
• files, terminals, disks, tapes, audio, network, peripheral devices
• device driver – Kernel module, typically LKM (Loadable Kernel Module)
• devices represented as special files
![Page 4: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/4.jpg)
Device Types
• Regular file• Block device (block special file)– similar to a disk, transfers information in blocks
• Character device (character special file)– terminal-like with a stream of bytes in order
• Network device– no device node, use name with socket to ioctl
• File-system device– Rarely directly access, through ioctl
![Page 5: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/5.jpg)
Uniform Device Access
• File descriptor 0 – STDIN_FILENO, 1 – STDOUT_FILENO, 2 – STDERR_FILENO
• open• close• read• write• ioctl
![Page 6: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/6.jpg)
Process Creation
• init – special process, parent of all processes
• fork• exec family: execle• wait
![Page 7: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/7.jpg)
Interrupts & Signals
• Interrupt generated by hardware, typically by external device drivers, and typically asynchronous
• Signal How software is notified of an asynchronous event
• Signal Handler – How a process catches and handles a generated signal
![Page 8: Linux API Dr. Michael L. Collard collard@cs.kent.edu 1.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf9a1a28abf838c923a2/html5/thumbnails/8.jpg)
Terminal Control
• Special Devices have special capabilities• termios.h• tcgetattr• tcsetattr