Developing a Multiserver Operating System Jakub Jerm February 3, - - PowerPoint PPT Presentation

developing a multiserver operating system
SMART_READER_LITE
LIVE PREVIEW

Developing a Multiserver Operating System Jakub Jerm February 3, - - PowerPoint PPT Presentation

Developing a Multiserver Operating System Jakub Jerm February 3, 2010 UINX.CZ What is a Multiserver OS? What is a Multiserver OS? microkernel-based OS, which is... What is a Multiserver OS? microkernel-based OS, which is...


slide-1
SLIDE 1

Developing a Multiserver Operating System

Jakub Jermář February 3, 2010 UINX.CZ

slide-2
SLIDE 2

What is a Multiserver OS?

slide-3
SLIDE 3

What is a Multiserver OS?

  • microkernel-based OS,

which is...

slide-4
SLIDE 4

What is a Multiserver OS?

  • microkernel-based OS,

which is...

  • ...multiserver
slide-5
SLIDE 5

What is a Multiserver OS?

  • microkernel-based OS,

which is...

  • ...multiserver

– composed of multiple

server tasks

slide-6
SLIDE 6

What is a Multiserver OS?

  • microkernel-based OS,

which is...

  • ...multiserver

– composed of multiple

server tasks

microkernel server task server task server task server task server task server task app task app task app task app task app task app task

slide-7
SLIDE 7

What is a Multiserver OS?

  • microkernel-based OS,

which is...

  • ...multiserver

– composed of multiple

server tasks

  • not every microkernel-

based OS is multiserver

microkernel server task server task server task server task server task server task app task app task app task app task app task app task

slide-8
SLIDE 8

What is a Multiserver OS?

  • microkernel-based OS,

which is...

  • ...multiserver

– composed of multiple

server tasks

  • not every microkernel-

based OS is multiserver

  • not every OS is

microkernel-based

microkernel server task server task server task server task server task server task app task app task app task app task app task app task

slide-9
SLIDE 9

OS Classification by Architecture

slide-10
SLIDE 10

OS Classification by Architecture

microkernel server task server task server task server task server task server task app task app task app task app task app task app task

multiserver- microkernel

slide-11
SLIDE 11

OS Classification by Architecture

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task

slide-12
SLIDE 12

OS Classification by Architecture

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task kernel app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task monolithic kernel

slide-13
SLIDE 13

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task kernel app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task monolithic kernel

slide-14
SLIDE 14

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task kernel app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task monolithic kernel

slide-15
SLIDE 15

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task monolithic kernel

slide-16
SLIDE 16

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel system task app task app task app task app task app task app task

multiserver- microkernel microkernel with single system task monolithic kernel

slide-17
SLIDE 17

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel

multiserver- microkernel microkernel with single system task monolithic kernel

slide-18
SLIDE 18

The Multiserver Advantage

microkernel server task server task server task server task server task server task app task app task app task app task app task app task microkernel

multiserver- microkernel microkernel with single system task monolithic kernel

slide-19
SLIDE 19

The Multiserver Advantage

microkernel server task server task server task server task app task app task app task app task app task microkernel

multiserver- microkernel microkernel with single system task monolithic kernel

slide-20
SLIDE 20

Pros and Cons Overview

slide-21
SLIDE 21

Pros and Cons Overview

Pros

  • Improved robustness

and fault isolation

  • Clean interface

between servers

  • Simpler components
  • Flexibility in

connecting components

slide-22
SLIDE 22

Pros and Cons Overview

Pros

  • Improved robustness

and fault isolation

  • Clean interface

between servers

  • Simpler components
  • Flexibility in

connecting components Cons

  • Worse performance
  • No cross-layer
  • ptimizations
slide-23
SLIDE 23

Multiserver-Microkernel Examples

slide-24
SLIDE 24

Multiserver-Microkernel Examples

Hurd http://hurd.gnu.org

slide-25
SLIDE 25

Multiserver-Microkernel Examples

Hurd http://hurd.gnu.org MINIX 3 http://minix3.org

slide-26
SLIDE 26

Multiserver-Microkernel Examples

Hurd http://hurd.gnu.org MINIX 3 http://minix3.org HelenOS http://helenos.org

slide-27
SLIDE 27

Simplified HelenOS Architecture

slide-28
SLIDE 28

Simplified HelenOS Architecture

microkernel SPARTAN

slide-29
SLIDE 29

Simplified HelenOS Architecture

microkernel SPARTAN Naming service Device mapper RAM disk driver VFS FAT DEVFS ATA disk driver MBR partition driver Task monitor i8042 driver Char mouse driver Framebuffer service Keyboard Service Console server Clipboard service GUID partition driver file backed block device GUID partition driver TMPFS

slide-30
SLIDE 30

Simplified HelenOS Architecture

microkernel SPARTAN Naming service Device mapper RAM disk driver VFS FAT Network packet server DEVFS ATA disk driver MBR partition driver Task monitor i8042 driver Char mouse driver Framebuffer service Keyboard Service Console server Clipboard service GUID partition driver file backed block device GUID partition driver TMPFS IP ICMP ARP TCP UDP loopback driver dp8390 driver nildummy Ethernet

slide-31
SLIDE 31

Simplified HelenOS Architecture

microkernel SPARTAN Naming service Device mapper RAM disk driver VFS FAT Network packet server DEVFS ATA disk driver MBR partition driver Task monitor i8042 driver Char mouse driver Framebuffer service Keyboard Service Console server Clipboard service GUID partition driver file backed block device GUID partition driver TMPFS IP ICMP ARP TCP UDP loopback driver dp8390 driver nildummy Ethernet Application

slide-32
SLIDE 32

Making it all hold together

slide-33
SLIDE 33

Making it all hold together

  • The previous slide shows 28 independent

server tasks running at one time

slide-34
SLIDE 34

Making it all hold together

  • The previous slide shows 28 independent

server tasks running at one time

  • Some servers may even run in multiple

instances

slide-35
SLIDE 35

Making it all hold together

  • The previous slide shows 28 independent

server tasks running at one time

  • Some servers may even run in multiple

instances

  • All servers provide some services to other

server tasks or applications; most servers require services from other servers

slide-36
SLIDE 36

Making it all hold together

  • The previous slide shows 28 independent

server tasks running at one time

  • Some servers may even run in multiple

instances

  • All servers provide some services to other

server tasks or applications; most servers require services from other servers

  • Together these server tasks provide the

services of the operating system

slide-37
SLIDE 37

Making it all hold together (II)

  • So how do these tasks communicate?
slide-38
SLIDE 38

Making it all hold together (II)

  • So how do these tasks communicate?
  • Both the monolithic OS and the single

system task microkernel OS deal only with

  • ne address space
slide-39
SLIDE 39

Making it all hold together (II)

  • So how do these tasks communicate?
  • Both the monolithic OS and the single

system task microkernel OS deal only with

  • ne address space
  • In a multiserver OS, the servers are in

separate address spaces

slide-40
SLIDE 40

Making it all hold together (II)

  • So how do these tasks communicate?
  • Both the monolithic OS and the single

system task microkernel OS deal only with

  • ne address space
  • In a multiserver OS, the servers are in

separate address spaces

  • Message passing provided by the kernel

– IPC

slide-41
SLIDE 41

HelenOS IPC

slide-42
SLIDE 42

HelenOS IPC

  • Message passing
slide-43
SLIDE 43

HelenOS IPC

  • Message passing

– unusual metaphor of making phone calls

and leaving a message in the answerbox

slide-44
SLIDE 44

HelenOS IPC

  • Message passing

– unusual metaphor of making phone calls

and leaving a message in the answerbox

  • Asynchronous
slide-45
SLIDE 45

HelenOS IPC

  • Message passing

– unusual metaphor of making phone calls

and leaving a message in the answerbox

  • Asynchronous
  • Number of communicating tasks can be 1,

2 or N

slide-46
SLIDE 46

HelenOS IPC

  • Message passing

– unusual metaphor of making phone calls

and leaving a message in the answerbox

  • Asynchronous
  • Number of communicating tasks can be 1,

2 or N

– communicating with self – communicating with a peer – peer forwards the call to third party

slide-47
SLIDE 47

HelenOS IPC (II)

  • Message ~ Phone call

– simple calls – combo calls

slide-48
SLIDE 48

HelenOS IPC (II)

  • Message ~ Phone call

– simple calls – combo calls

  • Simple calls

– Six 32-bit / 64-bit words of payload

slide-49
SLIDE 49

HelenOS IPC (II)

  • Message ~ Phone call

– simple calls – combo calls

  • Simple calls

– Six 32-bit / 64-bit words of payload

  • Combo calls

– memory sharing – large data block copying – tasks negotiate, kernel arbitrates

slide-50
SLIDE 50

Life with IPC

slide-51
SLIDE 51

Life with IPC

  • Restricting interactions between logical

components to IPC has some advantages

slide-52
SLIDE 52

Life with IPC

  • Restricting interactions between logical

components to IPC has some advantages

– the components understand a protocol – the protocol can be verified – the protocol can have many

implementations

slide-53
SLIDE 53

Life with IPC

  • Restricting interactions between logical

components to IPC has some advantages

– the components understand a protocol – the protocol can be verified – the protocol can have many

implementations

  • object oriented design
slide-54
SLIDE 54

Life with IPC (II)

  • It also brings some problems
slide-55
SLIDE 55

Life with IPC (II)

  • It also brings some problems

– writing IPC by hand is tedious compared to

mere function calls in monolithic designs

slide-56
SLIDE 56

Life with IPC (II)

  • It also brings some problems

– writing IPC by hand is tedious compared to

mere function calls in monolithic designs

  • could be generated from some high level

architecture description

  • all HelenOS IPC written by hand so far
slide-57
SLIDE 57

Life with IPC (II)

  • It also brings some problems

– writing IPC by hand is tedious compared to

mere function calls in monolithic designs

  • could be generated from some high level

architecture description

  • all HelenOS IPC written by hand so far

– it is difficult to implement non-trivial

protocols using asynchronous IPC

slide-58
SLIDE 58

Life with IPC (II)

  • It also brings some problems

– writing IPC by hand is tedious compared to

mere function calls in monolithic designs

  • could be generated from some high level

architecture description

  • all HelenOS IPC written by hand so far

– it is difficult to implement non-trivial

protocols using asynchronous IPC

  • callbacks and event loops
  • HelenOS has a framework for it
slide-59
SLIDE 59

Asynchronous framework

slide-60
SLIDE 60

Asynchronous framework

  • Makes the asynchronous communication a

pleasant experience

– no event loops – no callbacks

slide-61
SLIDE 61

Asynchronous framework

  • Makes the asynchronous communication a

pleasant experience

– no event loops – no callbacks

  • Introduces fibrils (userspace threads) to

already multithreaded tasks

– client's connection handled by a fibril in

server

– fibril can send asynchronous messages

and wait for them later

slide-62
SLIDE 62

Asynchronous framework (II)

thread task thread thread

~ ~ ~

~ ~ ~ ~ ~

fibrils task thread

~

~ ~

fibrils

slide-63
SLIDE 63

Asynchronous framework (II)

thread task thread thread

~ ~ ~

~ ~ ~ ~ ~

fibrils task thread

~

~ ~

fibrils

slide-64
SLIDE 64

Using async framework

slide-65
SLIDE 65

Using async framework

  • Waiting for a request

– callid = async_get_call(&call)

slide-66
SLIDE 66

Using async framework

  • Waiting for a request

– callid = async_get_call(&call)

  • Answer a request with n return values

– ipc_answer_n(callid, retval, ...)

slide-67
SLIDE 67

Using async framework

  • Waiting for a request

– callid = async_get_call(&call)

  • Answer a request with n return values

– ipc_answer_n(callid, retval, ...)

  • Send one message with n arguments

– msgid = async_send_n(phone, method, ...,

&answer)

slide-68
SLIDE 68

Using async framework

  • Waiting for a request

– callid = async_get_call(&call)

  • Answer a request with n return values

– ipc_answer_n(callid, retval, ...)

  • Send one message with n arguments

– msgid = async_send_n(phone, method, ...,

&answer)

  • Wait for an answer to a sent message

– async_wait_for(msgid, &retval0)

slide-69
SLIDE 69
  • Send of n arguments and receive of m

return values combined

– retval0 = async_req_n_m(phone,

method, ..., …)

Using async framework (II)

slide-70
SLIDE 70
  • Send of n arguments and receive of m

return values combined

– retval0 = async_req_n_m(phone,

method, ..., …)

  • Sharing memory

– async_share_in/out_start(phone, ...) – async_share_in/out_receive(&callid, ...) – async_share_in/out_finalize(callid, ...)

Using async framework (II)

slide-71
SLIDE 71
  • Copying data

– async_data_read/write_start(phone, ...) – async_data_read/write_receive(&callid, ...) – async_data_read/write_finalize(callid, …)

Using async framework (III)

slide-72
SLIDE 72
  • Copying data

– async_data_read/write_start(phone, ...) – async_data_read/write_receive(&callid, ...) – async_data_read/write_finalize(callid, …)

  • Fibrils often need to be synchronized

– Fibril synchronization primitives

  • Mutexes
  • Readers-Write locks
  • Condition variables

Using async framework (III)

slide-73
SLIDE 73

Code example

req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev_handle, flags, NULL); rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); if (rc != EOK) { ... } rc = async_data_write_start(vfs_phone, (void *) opts, str_size(opts)); if (rc != EOK) { ... } rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); if (rc != EOK) { ... } /* Ask VFS whether it likes fs_name. */ rc = async_req_0_0(vfs_phone, IPC_M_PING); if (rc != EOK) { ... } async_wait_for(req, &rc);

slide-74
SLIDE 74

Code example (II)

if (read) res = async_data_read_receive(&callid, NULL); else res = async_data_write_receive(&callid, NULL); if (read) fibril_rwlock_read_lock(&file->node->contents_rwlock); else fibril_rwlock_write_lock(&file->node->contents_rwlock); msg = async_send_3(fs_phone, read ? VFS_OUT_READ : VFS_OUT_WRITE, file->node->dev_handle, file->node->index, file->pos, &answer); ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); async_wait_for(msg, &rc); if (read) fibril_rwlock_read_unlock(&file->node->contents_rwlock); else fibril_rwlock_write_unlock(&file->node->contents_rwlock); ipc_answer_1(rid, rc, bytes);

slide-75
SLIDE 75

Code example (II)

if (read) res = async_data_read_receive(&callid, NULL); else res = async_data_write_receive(&callid, NULL); if (read) fibril_rwlock_read_lock(&file->node->contents_rwlock); else fibril_rwlock_write_lock(&file->node->contents_rwlock); msg = async_send_3(fs_phone, read ? VFS_OUT_READ : VFS_OUT_WRITE, file->node->dev_handle, file->node->index, file->pos, &answer); ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); async_wait_for(msg, &rc); if (read) fibril_rwlock_read_unlock(&file->node->contents_rwlock); else fibril_rwlock_write_unlock(&file->node->contents_rwlock); ipc_answer_1(rid, rc, bytes);

slide-76
SLIDE 76

Code example (II)

libc VFS TMPFS

slide-77
SLIDE 77

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
slide-78
SLIDE 78

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
slide-79
SLIDE 79

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
  • 3. VFS_OUT_READ
slide-80
SLIDE 80

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
  • 3. VFS_OUT_READ
  • 4. ipc_forward()
slide-81
SLIDE 81

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
  • 3. VFS_OUT_READ
  • 4. ipc_forward()
  • 5. ipc_answer(EOK)
slide-82
SLIDE 82

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
  • 3. VFS_OUT_READ
  • 4. ipc_forward()
  • 5. ipc_answer(EOK)
  • 6. ipc_answer(EOK)
slide-83
SLIDE 83

Code example (II)

libc VFS TMPFS

  • 1. VFS_IN_READ
  • 2. IPC_M_DATA_READ
  • 3. VFS_OUT_READ
  • 4. ipc_forward()
  • 5. ipc_answer(EOK)
  • 6. ipc_answer(EOK)
  • 7. ipc_answer(EOK)
slide-84
SLIDE 84

Demo

slide-85
SLIDE 85

Questions?

slide-86
SLIDE 86

www.helenos.org

jakub@jermar.eu