Professional Documents
Culture Documents
Iphone: Joseph Del Rocco Cop5611 April 2009
Iphone: Joseph Del Rocco Cop5611 April 2009
Iphone: Joseph Del Rocco Cop5611 April 2009
Outline
1. Hardware
2. Operating System
Overview / OS X / Darwin
XNU / Mach IPC / Thread Management Differences w/ iPhone
3. Development
3/6/2013
Hardware (3G)
3/6/2013
Motherboard (top)
3/6/2013
Motherboard (bottom)
3/6/2013
S3C6400 3/6/2013 6
32-bit RISC
32KB L1 (16x2 I/D) ARM TrustZone ARM Thumb
3/6/2013
L1 Cache
...evenly addressed double words are stored in one RAM, while oddly addressed double words are stored in the second RAM.
At synthesis time, the designer may choose to implement one, two or three separate RAMs. Where separate RAMs are implemented, the core can access these in parallel, hence increasing performance. [6]
3/6/2013
Memory (PoP)
8K blocks
4 banks Speed 7.5ns@CL3 1.8V core - 1.8V I/O
9
3/6/2013
Storage
K9MCG08U5M TH58NVG6D1D (3G)
--------------------------------------NOR faster non-contiguous reads, slow erase/write (read only) NAND faster erase/write, slow non-contiguous reads (serial) NAND prone to single-bit errors; error detection & correction
3/6/2013 10
Touch Screen
3/6/2013
11
Extras
3/6/2013
12
iPhone OS (?)
Remember that OS X on a Mac features a lot of applications that we dont have to ship on the iPhone.
Greg Joswiak Macworld Expo (01/2007)
The entire Mac OS is gigs, a lot is data. Take out the data -every desktop pattern, sound sample -- if you look at Safari it's not that big. It's REAL Safari, REAL OS X. We put a different user interface on it to work with a multi-touch screen...
Steve Jobs Wall Street Journal: D Conference (05/30/2007)
3/6/2013
13
OS X Lineage
3/6/2013
14
NeXTSTEP
... we at id Software developed DOOM and Quake on the NeXTSTEP 3.3 OS running on a variety of hardware for about 4 years. I still remember the wonderful time I had coding DoomEd and QuakeEd in Objective-C; there was nothing like it before and there still is no environment quite like it even today. John Romero http://rome.ro
I wrote the program using a NeXT computer. This had the advantage that there were some great tools available -it was a great computing environment in general. In fact, I could do in a couple of months what would take more like a year on other platforms, because on the NeXT, a lot of it was done for me already. Tim Berners-Lee http://www.w3.org/People/Berners-Lee/WorldWideWeb
3/6/2013 http://www.youtube.com/watch?v=j02b8Fuz73A 15
Apple using System Software 1984 - 1999 Apple talks w/ Microsoft, Be, Sun, NeXT. Apple acquires NeXT (1996) Apple initially pushes OPENSTEP (epic fail) Rhapsody = OPENSTEP, BSD, etc. Apple rushes OS X Server v1.0 (1999) Apple forks Rhapsody as Darwin (2000) Apple releases OS X v10.0 (2001)
3/6/2013
16
Darwin & OS X
3/6/2013
17
Darwin Source
3/6/2013
18
Layered
+ modular + simplicity / debugging - layers add overhead - layer order complexity (catch-22 scenarios)
Microkernel
+ ease of extending + hardware portability + reusable w/ OS layers
Hybrid / Modular
+ benefits of layered + dynamic-loaded extensions + IPC unnecessary between extensions - too many kernel extensions becomes -> monolithic
19
3/6/2013
...about 70 percent of operating systems consist of device drivers, which have error rates three to seven times higher than ordinary code... [22]
XNU
FreeBSD
process model user ids, permissions, basic security policies POSIX API, BSD style system calls TCP/IP stack, BSD sockets, firewall VFS, HFS and other file systems System V IPC cryptographic framework various synchronization mechanisms
I/O Kit
dynamic matching / loading of drivers / kext numerous device families (usb, pci, ata, etc.) i/o registry object oriented abstractions of devices power management an extensive API plug-and-play and hot-plugging driver stacking
Mach
preemptive multitasking, kernel threads protected memory virtual memory management (FIFO w/ second chance) inter-process communication interrupt management kernel debugging support console I/O
3/6/2013
20
Mach
Simplified kernel structure, easier to extend & modify BSD compatible; Heterogeneous system support; Mach-O binary format Support diverse architectures; mutliprocessors (UMA, NUMA, NORMA) Network transparency; Distributed operation internally & externally Fix UNIX design of everything-as-a-file; Generalize pipes to ports
Machs design philosophy is to have a simple, extensible kernel, concentrating on communication facilities. For instance, all requests to the kernel, and all data movement among processes, are handled through one communication mechanism. Mach is therefore able to provide system-wide protection to its users by protecting the communications mechanism. Optimizing this one communications path can result in significant performance gains, and it is simpler than trying to optimize several paths. [21]
3/6/2013
21
Thread
Basic unit of execution; shares parent tasks resources.
Port
Kernel-protected communication channel with access rights. Tasks must have proper rights to use the ports. Implemented as a protected, bounded queue within kernel.
Port Set
Group of ports sharing a common message queue.
Message
Basic method of communication between threads; collection of typed data or pointers.
Memory Object
Any source of memory where memory-mapped access makes sense; Tasks access it by mapping portions into their address spaces.
3/6/2013 22
Mach: IPC
Messages contain typed data for ease of interpretation Only one task may have receive rights to a port, many tasks may have send rights Essentially, IPC message passing implemented w/ shared memory (intra-computer)
3/6/2013
Cthreads API: create threads, destroy, wait, yield Mutual exclusion provided by spinlock mutexes Syncing w/out spinlock provided by condition variables
Cthreads Pthreads (1995)
24
3/6/2013
I/O Kit
3/6/2013
Background Processes
Only one iPhone application can run at a time, and third-party applications never run in the background.
iPhone Human Interface Guidelines, p16
[Here's why it's bad: battery life - it'll continue to drain your battery in the background); performance - background applications will suck up CPU cycles, slowing down your foreground application. Also not supported over the air.] [15]
Scott Forstall, VP iPhone Software, WWDC 2008
Apple provides server farm for your server apps Updates clients (badges, alert sounds, text messages)
26
OS X iPhone = considerably less than half a GB [14] OS X v10.0 = 800 MB (minimum) (2001) OS X v10.5.6 = 2.0 GB (atleast) (2009) A lot of drivers & software??? multiple file system formats, multiple drives, multiple volumes on drives, RAID, removable drives, real time system support, FireWire, CD/DVD, R/RW CD/DVD, printers, scanners, multiple users & preferences, Finder, fonts, screen savers, etc. kernel and driver-level interfaces not exposed
3/6/2013
ARM Thumb
...any code written in C could be executed successfully in Thumb state. However, device drivers and exception handlers must often be written at least partly in ARM state. [4] ...not all ARM instructions are available in the Thumb subset; [...] there's no way to access status or coprocessor registers. Also, some functions that can be accomplished in a single ARM instruction can only be simulated with a sequence of Thumb instructions. [4]
3/6/2013 28
3/6/2013
29
Mac OS X: APIs
3/6/2013
30
3/6/2013
31
3/6/2013
32
Shark
3/6/2013
33
Objective-C
Simula C
Small Talk
Developed 1985 interchangeable software components Licensed by NeXT 1988 Used by Apple (Cocoa API)
C++
ObjC
Protocols = Interfaces
34
3/6/2013
Examples
3/6/2013
35
References (Hardware)
1. http://www.apple.com/iphone/specs.html 2. http://dev.emcelettronica.com/touch-screen 3. http://www.embeddedstar.com/weblog/2007/12/05/st-lis331dl-lis331al/ 4. http://www.embedded.com/shared/printableArticle.jhtml?articleID=15200241 5. http://www.arm.com/products/CPUs/ARM1176.html 6. Lewin, Peter, May 2006, Cortex-R4: A comparison with the ARM9E processor family 7. http://www.imgtec.com/powervr/mbx.asp 8. http://www.techonline.com/product/underthehood/209000013 9. http://insidetronics.blogspot.com/ 10. http://toucharcade.com/2008/07/07/under-the-hood-the-iphones-gaming-mettle/ 11. http://reviews.cnet.com/8301-19512_7-10115256-233.html 12. http://www.eetimes.com/news/semi/showArticle.jhtml?articleID=200900740
3/6/2013
36
References (OS)
13. Silberschatz, Abraham, Greg Gagne, Peter Galvin; Operating System Concepts: 7th; John Wiley & Sons 2005 14. http://www.macworld.co.uk/ipod-itunes/news/index.cfm?newsid=16927 15. http://www.macworld.com/article/133867/2008/06/backgroundprocesses.html 16. http://en.wikipedia.org/wiki/Darwin_(operating_system) 17. http://osxbook.com/book/bonus/ancient/whatismacosx//arch_xnu.html 18. Singh, Amit; Mac OS X Internals: A Systems Approach; Addison-Wesley Professional 2006 19. http://developer.apple.com/macosx/coredata.html 20. http://www.roughlydrafted.com/RD/RDM.Tech.Q1.07/4B800F78-0F75-455A-9681-F186A4365805.html 21. http://codex.cs.yale.edu/avi/os-book/os8/online-dir/b.pdf (http://www.os-book.com) 22. Tanenbaum, Andrew S; Can We Make Operating Systems Reliable and Secure?; IEEE Computer 2006 23. http://www.w3.org/People/Berners-Lee/WorldWideWeb 24. http://rome.ro/2006/12/apple-next-merger-birthday.html
3/6/2013
37