37
The Android Linux Kernel (Part 1): Primary & Secondary Storage Mechanisms Douglas C. Schmidt [email protected] www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA

The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

The Android Linux Kernel (Part 1):

Primary & Secondary Storage Mechanisms

Douglas C. [email protected]

www.dre.vanderbilt.edu/~schmidt

Professor of Computer Science

Institute for Software

Integrated Systems

Vanderbilt University

Nashville, Tennessee, USA

Page 2: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

2

Learning Objectives in this Part of the Lesson1. Recognize the two types of storage

supported by Android Linux:primary & secondary storage

Page 3: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

3

Overview of Android Linux Primary & Secondary Storage Mechanisms

Page 4: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

4

Android Linux Kernel: Primary & Secondary Storage

C

• Android’s software instructions & data reside in two different types of storage

See en.wikipedia.org/wiki/Computer_data_storage

Page 5: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

5

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/Computer_data_storage#Primary_storage

C

• Android’s software instructions & data reside in two different types of storage

• Primary storage – Fast random access memory (RAM)

Page 6: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

6

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/Volatile_memory

C

• Android’s software instructions & data reside in two different types of storage

• Primary storage – Fast random access memory (RAM)

• The contents of volatile RAM arewiped out whenever a device isrebooted or loses power

Page 7: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

7

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/Computer_data_storage#Secondary_storage

C

• Android’s software instructions & data reside in two different types of storage

• Primary storage – Fast random access memory (RAM)

• Secondary storage – Slower flash memory

Page 8: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

8

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/Flash_memory

C

• Android’s software instructions & data reside in two different types of storage

• Primary storage – Fast random access memory (RAM)

• Secondary storage – Slower flash memory

• Flash is persistent storage that can be erased & reprogrammedelectronically

Page 9: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

9

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/Memory_hierarchy

C

• Primary & secondary storage are part ofa “memory hierarchy”

Page 10: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

10

Android Linux Kernel: Primary & Secondary Storage

C

• In general, being “higher” in this hierarchy has several implications

See en.wikipedia.org/wiki/Memory_bandwidth

Page 11: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

11

Android Linux Kernel: Primary & Secondary Storage

C

• In general, being “higher” in this hierarchy has several implications, e.g.

• Memory bandwidth is faster

• i.e., rate at which data can be read from or stored into

See en.wikipedia.org/wiki/Memory_bandwidth

Page 12: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

12

Android Linux Kernel: Primary & Secondary Storage

C

• In general, being “higher” in this hierarchy has several implications, e.g.

• Memory bandwidth is faster

• CPU access latency is lower

• i.e., time interval between when CPU initiates a call for fetch or store data & when the call completes

See en.wikipedia.org/wiki/Access_time

Page 13: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

13

Android Linux Kernel: Primary & Secondary Storage

C

• In general, being “higher” in this hierarchy has several implications, e.g.

• Memory bandwidth is faster

• CPU access latency is lower

• Cost is greater

• i.e., “faster” == “costlier”

See www.differencebetween.com/difference-between-primary-and-vs-secondary-memory

Page 14: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

14

Android Linux Kernel: Primary & Secondary Storage

C

• Processor cores operate on instructions & their associated data that reside in RAM

See en.wikipedia.org/wiki/Central_processing_unit#Operation

Page 15: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

15

Android Linux Kernel: Primary & Secondary Storage

See www.linfo.org/kernel_space.html

C

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

Page 16: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

16

Android Linux Kernel: Primary & Secondary Storage

C

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

• Kernel space is a protected region of RAM for running privileged operations

See en.wikipedia.org/wiki/CPU_modes

Page 17: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

17

Android Linux Kernel: Primary & Secondary Storage

C

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

• Kernel space is a protected region of RAM for running privileged operations

• Kernel space can be accessed by user processes only via system calls

See en.wikipedia.org/wiki/System_call

Linux system call interface (API)

Page 18: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

18

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

• All Android apps execute in user space RAM

C

Android Linux Kernel: Primary & Secondary Storage

See en.wikipedia.org/wiki/User_space

Linux system call interface (API)

Page 19: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

19

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

• All Android apps execute in user space RAM

• User space is a more restrictive protection domain than kernel space

C

Android Linux Kernel: Primary & Secondary Storage

Linux system call interface (API)

See www.linfo.org/user_space.html

Page 20: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

20

• Processor cores operate on instructions & their associated data that reside in RAM

• Android Linux executes in kernel space RAM

• All Android apps execute in user space RAM

• User space is a more restrictive protection domain than kernel space

• Apps running in user space normally can’t access RAM of other apps, unless explicitly allowed

C

Android Linux Kernel: Primary & Secondary Storage

Linux system call interface (API)

See “anonymous shared memory” discussion in part 3 of this lesson

Page 21: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

21See en.wikipedia.org/wiki/Random-access_memory#Recent_developments

C

Android Linux Kernel: Primary & Secondary Storage

• The cost & performance of primary & secondary storage has improved substantially in recent years

Page 22: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

22

C

Android Linux Kernel: Primary & Secondary Storage

• Primary storage (RAM) on Android mobile devices is constrained

See developer.android.com/training/articles/memory.html

Page 23: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

23

C

Android Linux Kernel: Primary & Secondary Storage

• Primary storage (RAM) on Android mobile devices is constrained, e.g.

• Form factor

In 2017 2-4 GB is common for mobile devices versus 8-64 GB on a desktop or laptop

Page 24: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

24

C

Android Linux Kernel: Primary & Secondary Storage

• Primary storage (RAM) on Android mobile devices is constrained, e.g.

• Form factor

• Price points

Lower cost mobile devices typically have much less RAM than higher cost devices

Page 25: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

25See en.wikipedia.org/wiki/Virtual_memory

C

Android Linux Kernel: Primary & Secondary Storage

• (Android) Linux’s virtual memory manager features address memory constraints

Flash

Page 26: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

26See en.wikipedia.org/wiki/Demand_paging

Android Linux Kernel: Primary & Secondary Storage

• (Android) Linux’s virtual memory manager features address memory constraints, e.g.

• Helps conserve RAM by not moving app instructions & data from secondary toprimary storage until they are accessed

virtual

address

disk

physical

address

C

Page 27: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

27See en.wikipedia.org/wiki/Memory-mapped_file

C

Android Linux Kernel: Primary & Secondary Storage

• (Android) Linux’s virtual memory manager features address memory constraints, e.g.

• Helps conserve RAM by not moving app instructions & data from secondary toprimary storage until they are accessed

• Accelerates I/O operations via memory mapping of files & hardware devices

File on Disk

Memory

Mapped

File

Page 28: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

28See en.wikipedia.org/wiki/Memory_management_unit

C

Android Linux Kernel: Primary & Secondary Storage

• (Android) Linux’s virtual memory manager features address memory constraints, e.g.

• Helps conserve RAM by not moving app instructions & data from secondary toprimary storage until they are accessed

• Accelerates I/O operations via memory mapping of files & hardware devices

• Protects an app’s private data in RAM from other apps

Page 29: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

29

C

Android Linux Kernel: Primary & Secondary Storage

• Secondary storage in Android Linuxis used to save data persistently

See developer.android.com/guide/topics/data/data-storage.html

Mechanisms Persistent Capability

Shared Preferences

Store private primitive data in key-value pairs

External Storage

Store public data on the shared external storage

Internal Storage

Store private data on the device memory

SQLite Databases

Store structured data in a private database

Page 30: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

30

C

Android Linux Kernel: Primary & Secondary Storage

• Secondary storage in Android Linuxis used to save data persistently

Mechanisms Persistent Capability

Shared Preferences

Store private primitive data in key-value pairs

External Storage

Store public data on the shared external storage

Internal Storage

Store private data on the device memory

SQLite Databases

Store structured data in a private database

Page 31: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

31

C

Android Linux Kernel: Primary & Secondary Storage

• Secondary storage in Android Linuxis used to save data persistently

Mechanisms Persistent Capability

Shared Preferences

Store private primitive data in key-value pairs

External Storage

Store public data on the shared external storage

Internal Storage

Store private data on the device memory

SQLite Databases

Store structured data in a private database

Android has been progressively enhancing security of external storage over time..

Page 32: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

32

C

Android Linux Kernel: Primary & Secondary Storage

• Secondary storage in Android Linuxis used to save data persistently

Mechanisms Persistent Capability

Shared Preferences

Store private primitive data in key-value pairs

External Storage

Store public data on the shared external storage

Internal Storage

Store private data on the device memory

SQLite Databases

Store structured data in a private database

Page 33: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

33

C

Android Linux Kernel: Primary & Secondary Storage

• Secondary storage in Android Linuxis used to save data persistently

Mechanisms Persistent Capability

Shared Preferences

Store private primitive data in key-value pairs

External Storage

Store public data on the shared external storage

Internal Storage

Store private data on the device memory

SQLite Databases

Store structured data in a private database

Page 34: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

34

C

Android Linux Kernel: Primary & Secondary Storage

User Space

KernelSpace

Virtual File System (VFS)

Flash Driver

Storage Device

Page Cache

YAFFSExt3/4

See www.all-things-android.com/content/understanding-android-file-hierarchy

• Android Linux supports secondary storage via its Virtual File System (VFS) framework

Page 35: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

35

C

Android Linux Kernel: Primary & Secondary Storage

User Space

KernelSpace

Virtual File System (VFS)

Flash Driver

Storage Device

Page Cache

YAFFSExt3/4

• Android Linux supports secondary storage via its Virtual File System (VFS) framework

• Each file system is implemented via a kernel module that registers the operations that it supports with VFS

See en.wikipedia.org/wiki/Loadable_kernel_module

Page 36: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

36

C

Android Linux Kernel: Primary & Secondary Storage

User Space

KernelSpace

Virtual File System (VFS)

Flash Driver

Storage Device

Page Cache

YAFFSExt3/4

See en.wikipedia.org/wiki/Flash_memory

• Android Linux supports secondary storage via its Virtual File System (VFS) framework

• Each file system is implemented via a kernel module that registers the operations that it supports with VFS

• Android Linux file systems support “flash memory” files that can be erased/reprogrammed electronically

Page 37: The Android Linux Kernel (Part 1): Primary & Secondary ...schmidt/cs891f/2018-PDFs/L... · 2 Learning Objectives in this Part of the Lesson 1. Recognize the two types of storage supported

37

End of the Android Linux Kernel: (Part 1) Primary &

Secondary Storage Mechanisms