43
Resource Management in Mungi A major design aspect of Mungi is to make the system as unintrusive as possible. cse/UNSW COMP9242 2002/S2 W13 P1

Resource Management in Mungi

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Resource Management in Mungi

Resource Management in Mungi

A major design aspect of Mungi is to make the system as unintrusiveas possible.

cse/UNSW COMP9242 2002/S2 W13 P1

Page 2: Resource Management in Mungi

Resource Management in Mungi

A major design aspect of Mungi is to make the system as unintrusiveas possible.

This means:

➜ no restrictions whatsoever on pointer/capability use,➜ presentation of a valid capability at any time should guarantee access,➜ object persistence is under full control of users (as traditional files)

The system should also not rely on “sensible” users, like askingusers to register/de-register “interest” in an object.

cse/UNSW COMP9242 2002/S2 W13 P1

Page 3: Resource Management in Mungi

Resource Management in Mungi

A major design aspect of Mungi is to make the system as unintrusiveas possible.

This means:

➜ no restrictions whatsoever on pointer/capability use,➜ presentation of a valid capability at any time should guarantee access,➜ object persistence is under full control of users (as traditional files)

The system should also not rely on “sensible” users, like askingusers to register/de-register “interest” in an object.

➜ How do we deal with garbage?

cse/UNSW COMP9242 2002/S2 W13 P1

Page 4: Resource Management in Mungi

RESOURCE MANAGEMENT . . .

Automatic garbage collection is impossible because:

➜ reference counting is impossible as system cannot track references,➜ scanning schemes cannot work as system cannot find pointers.

cse/UNSW COMP9242 2002/S2 W13 P2

Page 5: Resource Management in Mungi

RESOURCE MANAGEMENT . . .

Automatic garbage collection is impossible because:

➜ reference counting is impossible as system cannot track references,➜ scanning schemes cannot work as system cannot find pointers.

Quota:

➜ require checking whenever an object is allocated ⇒ overhead,➜ cannot distinguish between used and unused space.

What else?

cse/UNSW COMP9242 2002/S2 W13 P2

Page 6: Resource Management in Mungi

RESOURCE MANAGEMENT USING BANK ACCOUNTS

➜ Every object is associated with a bank account.➜ “Rent” is periodically collected from account for associated objects.➜ Regular “income” is periodically deposited into bank accounts.➜ Overdrawn accounts prevent further creation of persistent objects⇒ forces users to clean up.

➜ “Tax” on high balances prevents excessive accumulation of funds.

Based on similar ideas in Amoeba [MT86] and the Monash PasswordCapability System [APW86].

cse/UNSW COMP9242 2002/S2 W13 P3

Page 7: Resource Management in Mungi

GRACEFUL DEGRADATION

Q: How stop systemfrom brickwalling whendisk is full?

cse/UNSW COMP9242 2002/S2 W13 P4

Page 8: Resource Management in Mungi

GRACEFUL DEGRADATION

Q: How stop systemfrom brickwalling whendisk is full?

A: Market approach:adjust rent to demand!

1

10

100

0 0.2 0.4 0.6 0.8 1

stor

age

cost

storage utilisation

p=10p=1

p=0.1p=10-2

p=10-3

p=10-4

cse/UNSW COMP9242 2002/S2 W13 P4

Page 9: Resource Management in Mungi

FAIRNESS

Q: How stop someonefrom accumulating largeamounts of moneyenabling them to “buythe whole world”?

cse/UNSW COMP9242 2002/S2 W13 P5

Page 10: Resource Management in Mungi

FAIRNESS

Q: How stop someonefrom accumulating largeamounts of moneyenabling them to “buythe whole world”?

A: Taxation: limitbalance by imposing aprogressive tax!

0

1

2

3

4

5

6

7

8

0 2 4 6 8 10

post

-tax

bal

ance

pre-tax balance

b = 0.1b = 1b = 3

b = 10b = 100

no taxation

cse/UNSW COMP9242 2002/S2 W13 P5

Page 11: Resource Management in Mungi

RESOURCE MANAGEMENT ISSUES :

• Secondary memory — solved

• Primary memory — have a model, work to be done

• Kernel memory (TCBs) — to be done

• CPU time, scheduling — to be done➜ Lottery scheduling [WW94] worth looking at

• Network bandwidth — to be done

• ???

cse/UNSW COMP9242 2002/S2 W13 P6

Page 12: Resource Management in Mungi

Linking in Mungi

INHERENT FEATURES OF A SASOS:

➜ data have unique address, independent of context,➜ a particular address always refers to the same data.

cse/UNSW COMP9242 2002/S2 W13 P7

Page 13: Resource Management in Mungi

Linking in Mungi

INHERENT FEATURES OF A SASOS:

➜ data have unique address, independent of context,➜ a particular address always refers to the same data.

So, how keep private data of separate executions of the sameprogram separate?

➜ Can allocate stacks at unique addresses.➜ How about the data segment, in particular global static s?

⇒ Need to re-think linking.

cse/UNSW COMP9242 2002/S2 W13 P7

Page 14: Resource Management in Mungi

STATIC LINKING IN UNIX

.... .a

libc.amain.o

data

virt.addr.

initialised

space

Loader

crt0

.o

main.o .... .o libc.a

Linker

a.out

text stackdata bss

☛ all symbols resolved by linker

cse/UNSW COMP9242 2002/S2 W13 P8

Page 15: Resource Management in Mungi

DYNAMIC LINKING IN UNIX

datainitialised

spaceaddr.virt.

main.o

lib...

libc.so

Linker

a.out

text stackdata bss

Loader

crt0

.o

main.o .... .o

libc

☛ some symbols resolved by loader

cse/UNSW COMP9242 2002/S2 W13 P9

Page 16: Resource Management in Mungi

PROPERTIES OF DYNAMIC LINKING :

✌ Library code only exists in single copy (RAM and disk).

✌ New library versions immediately usable.

✌ Reduced startup latency if library resident.

♣ Execution fails if library removed.

♣ Overhead due to level of indirection.

cse/UNSW COMP9242 2002/S2 W13 P10

Page 17: Resource Management in Mungi

SYMBOL RESOLUTION AT LOAD TIME

data:main.o

GOT:main

printf

main.o

printf(...) printf() {...}

libc.so

data:libc.so

GOT:libc

➜ Loader enters external references into global object table (GOT).➜ Functions invoked by indirect jump via GOT.

cse/UNSW COMP9242 2002/S2 W13 P11

Page 18: Resource Management in Mungi

LAZY LOADING

➜ Delay library load time until first function invocation.➜ GOT initialised to point to stub code.➜ Stubs invoke lazy loader.➜ Loader fixed up pointers in GOT.

cse/UNSW COMP9242 2002/S2 W13 P12

Page 19: Resource Management in Mungi

LAZY LOADING

➜ Delay library load time until first function invocation.➜ GOT initialised to point to stub code.➜ Stubs invoke lazy loader.➜ Loader fixed up pointers in GOT.

Features:

✌ Reduce startup latency (at expense of later stalls).

✌ Save overhead for libraries not actually invoked.

♣ Delayed failure if library not available.

cse/UNSW COMP9242 2002/S2 W13 P12

Page 20: Resource Management in Mungi

DYNAMIC LINKING PROBLEMS

Position of library code is not know at library link time⇒ library must use position-independent code (PIC).

cse/UNSW COMP9242 2002/S2 W13 P13

Page 21: Resource Management in Mungi

DYNAMIC LINKING PROBLEMS

Position of library code is not know at library link time⇒ library must use position-independent code (PIC).

☛ All jumps must be: ❏ PC-relative,❏ off a register, or❏ indirect (via GOT).

☛ Every function must first locate GOT (via PC-relative load)⇒ overhead.

cse/UNSW COMP9242 2002/S2 W13 P13

Page 22: Resource Management in Mungi

THE GLOBAL OFFSET TABLE IS private static data :

• Global to library⇒ cannot be on stack.

• Private to invocation⇒ every process needs own copy.

⇒ GOT cannot be allocated at a fixed address.

⇒ GOT must be allocated in a per-library data segmentat known (at link-time) offset from library code(to allow PC-relative addressing).

Same holds for any variables declared static or extern in librarye.g.: errno

cse/UNSW COMP9242 2002/S2 W13 P14

Page 23: Resource Management in Mungi

L INKING IN A SASOS

• Static linking works as in UNIX (with same drawbacks)except for private static data.

cse/UNSW COMP9242 2002/S2 W13 P15

Page 24: Resource Management in Mungi

L INKING IN A SASOS

• Static linking works as in UNIX (with same drawbacks)except for private static data.

• Why copy when everything is in the address space anyway?

main.o

printf(...)printf() {...}

libc.a

Virtual address space

Can execute library code in place.

☛ Called global static linking [CLFL94] (all references resolved at linktime).

cse/UNSW COMP9242 2002/S2 W13 P15

Page 25: Resource Management in Mungi

FEATURES OF GLOBAL STATIC LINKING

✌ Code sharing (as for dynamic linking).

♣ No automatic replacement of libraries,re-linking required (as for static linking).

♣ Removing library results in failure (as for dynamic linking).

♣ Cannot have private static data in library.

☛ Private static data is a problem for dynamic linking too.

cse/UNSW COMP9242 2002/S2 W13 P16

Page 26: Resource Management in Mungi

PROBLEMS WITH PRIVATE STATIC DATA

• Same address ⇒ same data in a SASOS

⇒ Different processes’ private static datamust be allocated at different addresses.

⇒ Need per-invocation, per-library data segments.

• How to locate data segment?

cse/UNSW COMP9242 2002/S2 W13 P17

Page 27: Resource Management in Mungi

PROBLEMS WITH PRIVATE STATIC DATA

• Same address ⇒ same data in a SASOS

⇒ Different processes’ private static datamust be allocated at different addresses.

⇒ Need per-invocation, per-library data segments.

• How to locate data segment?➜ Cannot use PC-relative addressing.➜ Caller must pass address to callee:

? explicit parameter (Nemesis [Ros95]),? global pointer register (Mungi [DH99]).

✌ No overhead for intra-module calls.

cse/UNSW COMP9242 2002/S2 W13 P17

Page 28: Resource Management in Mungi

DYNAMIC LINKING IN MUNGI

libc data

libc.datalibc:strlenlibc:atoi ...

libz data

libc code

int atoi() { ... }

size_t strlen() { ... }

libz code

void aa() { ... }

int bb() { ... }

libc.datalibc:strlenlibc:atoi ...libz.data

libz:aalibz:bb ...

main data

main code

void main() { ... }

Module descriptor contains:➜ pointer to module’s data segment,➜ pointers to imported functions.

cse/UNSW COMP9242 2002/S2 W13 P18

Page 29: Resource Management in Mungi

DYNAMIC LINKING IN MUNGI...

• Calling sequence differs between local and cross-moduleinvocation

☛ supported by modified GNU assembler.

• Cross-module calling overhead is about 3 instructions.

• Module description objects specify module interface.

• Function pointers consist of(entrypoint address, global pointer value).

☛ Appropriate compiler modification not done yet.

cse/UNSW COMP9242 2002/S2 W13 P19

Page 30: Resource Management in Mungi

MODULE DESCRIPTION OBJECT

libc.mm:[IMPORTS]

[EXPORTS]strlenbcopy...

[OBJECTS]c1.oc2.o...

main.mm:[IMPORTS]libc.mm

[EXPORTS]

[OBJECTS]main.osub.o...

cse/UNSW COMP9242 2002/S2 W13 P20

Page 31: Resource Management in Mungi

CODE PREPARATION PROCESS

c1.s

gas

gcc

c1.o

ml

libc.mm

c1.c

c2.o

libc.md

ml

main.o

gas

main.mdlibc.md main.s

a.out

cse/UNSW COMP9242 2002/S2 W13 P21

Page 32: Resource Management in Mungi

PROBLEMS : EXPORTED VARIABLES

Cannot do: extern int errno;

cse/UNSW COMP9242 2002/S2 W13 P22

Page 33: Resource Management in Mungi

PROBLEMS : EXPORTED VARIABLES

Cannot do: extern int errno;

☛ Bad practice anyway, changed to:extern int *__errno();#define errno (*(__errno()))

for multi-threading support in ➜ Solaris,➜ Digital Unix,➜ Irix,➜ Linux, ...

cse/UNSW COMP9242 2002/S2 W13 P22

Page 34: Resource Management in Mungi

PERFORMANCE

Irix/32-bit/SGI-cc Mungi/64-bit/GCCstatic dynamic dyn/stat static dynamic dyn/stat

lookup 7.26(3) 8.02(3) 1.104(10) 7.568(6) 8.199(4) 1.083(3)f. trav. 4.77(3) 5.17(4) 1.084(15) 6.013(6) 6.040(3) 1.004(6)b. trav. 5.13(2) 5.68(4) 1.107(12) 6.976(4) 7.011(4) 1.005(1)insert 4.61(2) 5.02(2) 1.087(10) 4.528(4) 4.755(3) 1.051(1)total 21.7(1) 23.9(1) 1.097(12) 25.08(1) 26.00(1) 1.037(1)

cse/UNSW COMP9242 2002/S2 W13 P23

Page 35: Resource Management in Mungi

PERFORMANCE

Irix/32-bit/SGI-cc Mungi/64-bit/GCCstatic dynamic dyn/stat static dynamic dyn/stat

lookup 7.26(3) 8.02(3) 1.104(10) 7.568(6) 8.199(4) 1.083(3)f. trav. 4.77(3) 5.17(4) 1.084(15) 6.013(6) 6.040(3) 1.004(6)b. trav. 5.13(2) 5.68(4) 1.107(12) 6.976(4) 7.011(4) 1.005(1)insert 4.61(2) 5.02(2) 1.087(10) 4.528(4) 4.755(3) 1.051(1)total 21.7(1) 23.9(1) 1.097(12) 25.08(1) 26.00(1) 1.037(1)

PERFORMANCE : A PPLES VS APPLES (I.E., 64-BIT STATIC )

Irix Mungi Mungi/Irixgood bad good bad

lookup 7.367 7.169 7.452 0.973 1.012forward traverse 5.904 6.085 6.079 1.031 1.030backward traverse 6.796 6.992 6.991 1.029 1.029insert 4.755 4.724 4.801 0.993 1.010total 24.822 24.970 25.323 1.006 1.020

cse/UNSW COMP9242 2002/S2 W13 P23

Page 36: Resource Management in Mungi

CONCLUSIONS

☛ Mungi’s dynamic linking overhead is significantly lower than Irix’

☛ Irix’s higher overhead is inherent in multi-address-space approach:➜ Irix cannot guarantee that library can always be mapped to same address.⇒ Irix cannot execute “in-place”.⇒ Irix cannot avoid using position-independent code.

• Compare quickstart facility in Digital Unix [DEC94]:allocate libraries at fixed addresses.

☛ Single-address-space system reduce costs.

cse/UNSW COMP9242 2002/S2 W13 P24

Page 37: Resource Management in Mungi

Mungi: Recent Achievements

• Source release

• Component system for extensibility

• Posix emulation

• Driver framework➜ user-level drivers (serial, display, IDE, Ethernet on Alpha)

• New thread model➜ integrated with normal Mungi access control for memory

• Ported to portable L4 kernel (Pistachio)➜ runs on Itanium, Alpha, MIPS

• Persistence

cse/UNSW COMP9242 2002/S2 W13 P25

Page 38: Resource Management in Mungi

Present Mungi-related activities:

• Fast I/O system for Mungi (based on LFS idea)

• Self-hosting

• User/login model

• SMP

• Distribution of address space

cse/UNSW COMP9242 2002/S2 W13 P26

Page 39: Resource Management in Mungi

Present Mungi-related activities:

• Fast I/O system for Mungi (based on LFS idea)

• Self-hosting

• User/login model

• SMP

• Distribution of address space

• Run on my desktop/laptop

cse/UNSW COMP9242 2002/S2 W13 P26

Page 40: Resource Management in Mungi

Other OS Research at UNSW

MungiSASOS

MIPSAlphaStrongARMSPARC

L4 nucleus L Linux4

SMP scheduling

64−bitpage tables

high−performancelog−structuredswap file system

Linux/IA−64efficient sharing

embeddedsystems

PLEB

CPUsimulator

Sulima

cse/UNSW COMP9242 2002/S2 W13 P27

Page 41: Resource Management in Mungi

References

[APW86] Mark Anderson, Ronald Pose, and Chris S. Wallace. Apassword-capability system. The Comp. J., 29:1–8, 1986.

[CLFL94] Jeffrey S. Chase, Henry M. Levy, Michael J. Feeley, andEdward D. Lazowska. Sharing and protection in asingle-address-space operating system. Trans. Comp.Syst., 12:271–307, 1994.

[DEC94] Digital Equipment Corp. DEC OSF/1 Programmer’s Guide,1994. Order No AA-PS30C-TE.

[DH99] Luke Deller and Gernot Heiser. Linking programs in a

cse/UNSW COMP9242 2002/S2 W13 P28

Page 42: Resource Management in Mungi

single address space. In Proc. 1999 Techn. Conf., pages283–294, Monterey, Ca, USA, Jun 1999.

[MT86] Sape J. Mullender and Andrew S. Tanenbaum. The designof a capability-based distributed operating system. TheComp. J., 29:289–299, 1986.

[Ros95] Timothy Roscoe. The Structure of a Multi-ServiceOperating System. PhD thesis, University of CambridgeComputer Laboratory, Apr 1995. TR-376, URLhttp://www.cl.cam.ac.uk/ftp/papers/reports/TR376-tr-multi-service-os.ps.gz .

[WW94] Carl A. Waldspurger and William E. Weihl. Lotteryscheduling: Flexible proportional-share resource

cse/UNSW COMP9242 2002/S2 W13 P29

Page 43: Resource Management in Mungi

management. In Proc. 1st OSDI, pages 1–11, Monterey,CA, USA, Nov 1994.

cse/UNSW COMP9242 2002/S2 W13 P30