Computer skills Pointer, record, storage, file system
0K - views

Computer skills Pointer, record, storage, file system

Similar presentations


Download Presentation

Computer skills Pointer, record, storage, file system




Download Presentation - The PPT/PDF document "Computer skills Pointer, record, storage..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.



Presentation on theme: "Computer skills Pointer, record, storage, file system"— Presentation transcript:

Slide1

Computer skills

Pointer, record, storage, file system

Jakub Yaghob

Slide2

Variable

Variable

Named storage location which contains some value of a type

Storage location → address

var i : integer; f : real; b : array[1..5] of integer;

I

F

B[1]

B[2]

B[3]

B[4]

B[5]

4B

8B

4B

4B

4B

4B

4B

A

A+16

A+20

A+24

A+28

A+4

A+12

A+32

Slide3

Alignment

Modern CPUs require data in memory aligned to their size

E.g. integer (4B) must have address aligned to 4

I

F

B[1]

B[2]

B[3]

B[4]

B[5]

4B

8B

4B

4B4B4B

4B

var

i

: integer; f : real;

b : array[1..5] of integer;

4B

A

A+16

A+20

A+24

A+28

A+4

A+8

A+32

A+36

Slide4

Record/structure

A group of related data

Access to record fields

r.age

var r : record age : integer;

name,surname : string;

sex : char;

end;

Slide5

Record/structure – example 1

var

r : record

i : integer; d : real;

end;

I

D

8B

4B

A

A+4A+12

I

D

8B

4B

A

A+4

A+16

4B

A+8

Slide6

Sizeof

Size of a type in bytes

Predefined for base types

array [LB..UB] of T

(UB-LB+1) x sizeof(T)record - not enough, must be aligned 

Slide7

Record/structure – example 2

var

r : record

i : integer; d : real; c : char;

end;

I

D

8B

4B

A

A+4A+12

I

D

8B

4B

A

A+4

A+16

4B

A+8

C

A+13

C

A+17

1

B

1

B

I

D

8B

4B

A

A+4

A+16

4B

A+8

C

A+17

1

B

A+24

7

B

Slide8

Pointer

Address type for storing an address

Typeless

pointerPointer to a typePascal

Declarationvar p : ^integer;Dereferencingp^Address of@i

Slide9

Pointer – example

var

i,j : integer; p1,p2 : ^integer;

begin

p1:=@

i; p2:=@j; write(p1^);

p1:=p2; write(p1^);end

I

J

P1

P2

Slide10

Pointer – advanced example

type

node = record

i : integer; next : ^node;

end;

var

list : ^node;

LIST

I

NEXT

INEXT

I

NEXT

nil

LIST

I

NEXT

I

NEXT

I

NEXT

nil

Slide11

External storage

Capacity larger then operating memory

Slower then operating memory

Not directly addressable by CPU

Sectors512B x 4KAddressingLBA x CHSHDDRotating platters, heads, clustersSSDFlash modules

Slide12

Multiples of bytes

Decimal

Binary

1000

kBkilobyte1024KiB kibibyte10002MBmegabyte

10242MiB

mebibyte1000

3GBgigabyte10243GiBgibibyte10004

TBterabyte10244TiBtebibyte10005

PBpetabyte10245PiBpebibyte10006

EBexabyte10246EiBexbibyte10007ZB

zettabyte10247ZiBzebibyte10008YB

yottabyte10248YiByobibyte

Slide13

File

File

Resource for storing data in a storage device

Sequence of bytesText file x binary file

File headerOperationsopenread/writeseekclose

Slide14

File system

File system

File naming

File storage/placementFree space managementDirectory

Helps to organize filesMany known filesystemsFAT, NTFS, EXT2, XFS, …

Slide15

Data structure examples

FAT16 directory entry

0

1

23456789

AB

CD

EF0File name

ExtensionAtrCreate T

10Cre DAcc D

Update DTClusterFile size

Slide16

Data structure examples

IP packet header