Cirrus Logic CS485 Manual de usuario Pagina 46

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 45
CS485G Spring 2015 46
(b) The POSIX standard requires 117 functions, such as write(),
to be safe. But printf() is not safe.
51 Nonlocal jumps
1. Nonlocal jumps provide a powerful but dangerous method to trans-
fer control to an arbitrary location.
2. int setjmp(jmp buf jb): saves a “snapshot” in jmp buf. It
may return multiple times; the first time it returns 0.
3. The snapshot contains register information, including pc and sp.
4. void longjmp(jmp buf jb, int val): causes a return from
the associated setjmp, with val as the return value.
52 Files
1. Unix files are sequences of bytes. The kernel does not distinguish
files built for various purposes (text, data, object) when a process
reads or write them, no matter what the file name might be.
2. Even non-file abstractions are made to look like files to allow pro-
cesses to treat them in a consistent way.
(a) Even devices look like files. They have names like /dev/tty1
and /dev/sda2. Some are character special, like terminals.
Others are block special, like disks.
(b) The kernel memory can be seen as a file: /dev/kmem.
(c) Information about processes look like files: /proc/
(d) Directories are special, in that they are not read/written us-
ing read() and write(). Directories contain names of files,
building a hierarchical file arrangement.
(e) Pipes, used for inter-process communication, also look like files.
(f) A FIFO is like a pipe, but it has a name in the file system.
(g) A socket is used for cross-machine inter-process communica-
tion. Processes usually use recv() and send(), not read()
and write().
3. Basic I/O system calls. Always check the return value!
Vista de pagina 45
1 2 ... 41 42 43 44 45 46 47 48 49 50 51 ... 66 67

Comentarios a estos manuales

Sin comentarios