Linux API Dr. Michael L. Collard [email protected] 1.

8
Linux API Dr. Michael L. Collard www.sdml.info/collard www.sdml.info/collard/linux [email protected] 1

Transcript of Linux API Dr. Michael L. Collard [email protected] 1.

Page 1: Linux API Dr. Michael L. Collard   collard@cs.kent.edu 1.

Linux API

Dr. Michael L. Collardwww.sdml.info/collard

www.sdml.info/collard/[email protected]

1

Page 2: Linux API Dr. Michael L. Collard   collard@cs.kent.edu 1.

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.

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.

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.

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.

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.

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.

Terminal Control

• Special Devices have special capabilities• termios.h• tcgetattr• tcsetattr