iPhone.ppt

45,037 views

Published on

Published in: Technology, News & Politics
6 Comments
14 Likes
Statistics
Notes
No Downloads
Views
Total views
45,037
On SlideShare
0
From Embeds
0
Number of Embeds
140
Actions
Shares
0
Downloads
1,621
Comments
6
Likes
14
Embeds 0
No embeds

No notes for slide
  • Note: 2 boards SIM card SoC CPU
  • iPhone.ppt

    1. 1. iPhone <ul><li>Joseph Del Rocco </li></ul><ul><li>COP5611 </li></ul><ul><li>April 2009 </li></ul>
    2. 2. Outline <ul><li>Hardware </li></ul><ul><ul><li>CPU / GPU / Cache </li></ul></ul><ul><ul><li>Memory / Storage / Extras </li></ul></ul><ul><li>Operating System </li></ul><ul><ul><li>Overview / OS X / Darwin </li></ul></ul><ul><ul><li>XNU / Mach </li></ul></ul><ul><ul><li>IPC / Thread Management </li></ul></ul><ul><ul><li>Differences w/ iPhone </li></ul></ul><ul><li>Development </li></ul><ul><ul><li>SDK / Tools / Objective-C / Examples </li></ul></ul>
    3. 3. Hardware (3G)
    4. 4. Motherboard (top)
    5. 5. Motherboard (bottom)
    6. 6. Samsung S5L8900 (SoC) S3C6400
    7. 7. CPU / GPU Specs <ul><li>ARM1176JZ(F)-S </li></ul><ul><li>412 MHz (620 MHz) </li></ul><ul><li>103MHz FS Bus </li></ul><ul><li>32-bit RISC </li></ul><ul><li>32KB L1 (16x2 I/D) </li></ul><ul><li>ARM TrustZone </li></ul><ul><li>ARM Thumb </li></ul><ul><li>PowerVR MBX Lite </li></ul><ul><li>133 MHz (233 MHz) </li></ul><ul><li>~130m pix/s fillrate </li></ul><ul><li>~1.7m tri/s fill rate </li></ul><ul><li>Anti-Aliasing </li></ul><ul><li>Texture Compression </li></ul><ul><li>OpenGL ES / D3D M </li></ul>
    8. 8. L1 Cache <ul><li>“ ...evenly addressed double words are stored in one RAM, while oddly addressed double words are stored in the second RAM. </li></ul><ul><li>At synthesis time, the designer may choose to implement one, two or three separate RAMs. </li></ul><ul><li>Where separate RAMs are implemented, the core can access these in parallel, hence increasing performance.” [6] </li></ul>
    9. 9. Memory (PoP) <ul><li>DDR-SDRAM </li></ul><ul><li>1Gb (128MB) </li></ul><ul><li>(16MB reserved for GPU) </li></ul><ul><li>8K blocks </li></ul><ul><li>4 banks </li></ul><ul><li>Speed 7.5ns@CL3 </li></ul><ul><li>1.8V core - 1.8V I/O </li></ul>
    10. 10. Storage <ul><li>K9MCG08U5M </li></ul><ul><li>TH58NVG6D1D (3G) </li></ul><ul><li>NAND Flash Memory </li></ul><ul><li>4GB / 8GB / 16GB </li></ul><ul><li>2 GB dies (x2 / x4 / x8) </li></ul><ul><li>--------------------------------------- </li></ul><ul><li>NOR faster non-contiguous reads, slow erase/write (read only) </li></ul><ul><li>NAND faster erase/write, slow non-contiguous reads (serial) NAND prone to single-bit errors; error detection & correction </li></ul>
    11. 11. Touch Screen <ul><li>Broadcom BCM5974 Controller </li></ul><ul><li>Multi-touch </li></ul><ul><li>No stylus or non-conductive gloves </li></ul>
    12. 12. Extras <ul><li>STMicro LIS331 DL/AL Accelerometer </li></ul><ul><li>click & double-click </li></ul><ul><li>wake-up </li></ul><ul><li>motion detection </li></ul><ul><li>acceleration (x, y, z) axes </li></ul><ul><li>high-pass filters </li></ul><ul><li>2 dedicated interrupt lines </li></ul><ul><li>Hammerhead II PMB2525 GPS </li></ul><ul><li>2m steady state accuracy </li></ul><ul><li>< 50mm 2 PCB area </li></ul><ul><li>smart power management </li></ul><ul><li>multi-path mitigation </li></ul>
    13. 13. iPhone OS (?) <ul><li>“ Remember that OS X on a Mac features a lot of applications that we don’t have to ship on the iPhone.” </li></ul><ul><li>Greg Joswiak </li></ul><ul><li>Macworld Expo (01/2007) </li></ul><ul><li>“ 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...” </li></ul><ul><li>Steve Jobs </li></ul><ul><li>Wall Street Journal: D Conference (05/30/2007) </li></ul>
    14. 14. OS X Lineage
    15. 15. NeXTSTEP <ul><li>“ ... 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.” </li></ul><ul><li>John Romero </li></ul><ul><li>http://rome.ro </li></ul><ul><li>“ 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.” </li></ul><ul><li>Tim Berners-Lee </li></ul><ul><li>http://www.w3.org/People/Berners-Lee/WorldWideWeb </li></ul>http://www.youtube.com/watch?v=j02b8Fuz73A
    16. 16. NeXTSTEP -> OPENSTEP -> Rhapsody -> Darwin -> OS X 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) http://www.roughlydrafted.com/RD/RDM.Tech.Q1.07/4B800F78-0F75-455A-9681-F186A4365805.html
    17. 17. Darwin & OS X
    18. 18. Darwin Source
    19. 19. Mac OS X Kernel: XNU Layered + modular + simplicity / debugging - layers add overhead - layer order complexity (catch-22 scenarios) Microkernel + ease of extending + hardware portability + reusable w/ OS layers - performance decrease due to extensive IPC Hybrid / Modular + benefits of layered + dynamic-loaded extensions + IPC unnecessary between extensions - too many kernel extensions becomes -> monolithic “ ...about 70 percent of operating systems consist of device drivers, which have error rates three to seven times higher than ordinary code...” [22]
    20. 20. XNU <ul><li>preemptive multitasking, kernel threads </li></ul><ul><li>protected memory </li></ul><ul><li>virtual memory management (FIFO w/ second chance) </li></ul><ul><li>inter-process communication </li></ul><ul><li>interrupt management </li></ul><ul><li>kernel debugging support </li></ul><ul><li>console I/O </li></ul><ul><li>process model </li></ul><ul><li>user ids, permissions, basic security policies </li></ul><ul><li>POSIX API, BSD style system calls </li></ul><ul><li>TCP/IP stack, BSD sockets, firewall </li></ul><ul><li>VFS, HFS and other file systems </li></ul><ul><li>System V IPC </li></ul><ul><li>cryptographic framework </li></ul><ul><li>various synchronization mechanisms </li></ul><ul><li>dynamic matching / loading of drivers / kext </li></ul><ul><li>numerous device families (usb, pci, ata, etc.) </li></ul><ul><li>i/o registry </li></ul><ul><li>object oriented abstractions of devices </li></ul><ul><li>power management </li></ul><ul><li>an extensive API </li></ul><ul><li>plug-and-play and hot-plugging </li></ul><ul><li>driver stacking </li></ul>Mach I/O Kit FreeBSD
    21. 21. Mach <ul><li>Simplified kernel structure, easier to extend & modify </li></ul><ul><li>BSD compatible; Heterogeneous system support; Mach-O binary format </li></ul><ul><li>Support diverse architectures; mutliprocessors (UMA, NUMA, NORMA) </li></ul><ul><li>Network transparency; Distributed operation internally & externally </li></ul><ul><li>“ Fix” UNIX design of “everything-as-a-file”; Generalize pipes to ports </li></ul>“ Mach’s 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]
    22. 22. Mach: System Components <ul><li>Task Contains virtual address space, threads, & protected access to system resources via ports. </li></ul><ul><li>Thread B asic unit of execution; shares parent tasks’ resources. </li></ul><ul><li>P ort K ernel-protected communication channel with access rights. Tasks must have proper rights to use the ports. Implemented as a protected, bounded queue within kernel. </li></ul><ul><li>Port Set G roup of ports sharing a common message queue. </li></ul><ul><li>Message B asic method of communication between threads; collection of typed data or pointers. </li></ul><ul><li>M emory Object Any source of memory where memory-mapped access makes sense; Tasks access it by mapping portions into their address spaces. </li></ul>
    23. 23. Mach: IPC <ul><li>Messages contain typed data for ease of interpretation </li></ul><ul><li>Only one task may have receive rights to a port, many tasks may have send rights </li></ul><ul><li>Essentially, IPC message passing implemented w/ shared memory (intra-computer) </li></ul><ul><li>Note this mechanism can also used for process synchronization! </li></ul><ul><li>“ All other interprocess communications mechanisms in Mac OS X are implemented using Mach ports at some level” - Mac OS X Technology Overview </li></ul>
    24. 24. Mach: Task Management <ul><li>One-to-One mapping of User threads to Kernel threads </li></ul><ul><li>Only threads that cause page faults or makes a system call is suspended, the rest continue executing </li></ul><ul><li>Scheduler only deals w/ threads, has no knowledge of tasks (Sys-ConSco) </li></ul><ul><li>Priority Scheduling used (0 -127); “exponential average of CPU usage” </li></ul><ul><li>32 global run queues; Per processor “local” queues (device driver) (priority) </li></ul><ul><li>Time quantum varies inversely w/ total # of threads in system (thrds < cpus) </li></ul><ul><li>Cthreads API: create threads, destroy, wait, yield Mutual exclusion provided by spinlock mutexes Syncing w/out spinlock provided by condition variables </li></ul><ul><li>Cthreads -> Pthreads (1995) </li></ul>
    25. 25. I/O Kit <ul><li>Implemented w/ libkern to provide OOP </li></ul><ul><li>Recommended if software is used by the kernel itself, user-space programs, or software needs to respond directly to primary interrupts </li></ul>
    26. 26. Background Processes <ul><li>“ Only one iPhone application can run at a time, and third-party applications never run in the background.” </li></ul><ul><li>iPhone Human Interface Guidelines, p16 </li></ul><ul><li>[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] </li></ul><ul><li>Scott Forstall, VP iPhone Software, WWDC 2008 </li></ul><ul><li>Unified Push Notification </li></ul><ul><ul><li>Apple provides server farm for your server apps </li></ul></ul><ul><ul><li>Updates clients (“badges”, “alert sounds”, “text messages”) </li></ul></ul>
    27. 27. So... What Did They Take Out? <ul><li>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) </li></ul><ul><li>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. </li></ul><ul><li>kernel and driver-level interfaces not exposed </li></ul><ul><li>No garbage collector on iPhone imp. of Obj-C </li></ul><ul><li>ARM Thumb compiled code is quite compact (~35% smaller) </li></ul>
    28. 28. 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]
    29. 29. iPhone Reference Library “ ...system libraries and frameworks of iPhone OS […] are a subset of the libraries and frameworks on Mac OS X. For example, there is no Carbon application environment on iPhone OS, there is no command-line access (the BSD environment), there are no printing frameworks and services , and QuickTime is absent from the platform. However, because of the nature of the devices supported by iPhone OS, there are some frameworks, both public and private, that are specific to iPhone OS.”
    30. 30. Mac OS X: APIs
    31. 31. XCode + Interface Builder
    32. 32. IB: Connecting Components
    33. 33. Shark
    34. 34. Objective-C <ul><li>Message Handlers vs. Methods </li></ul><ul><li>Dynamic Typing (use types according to runtime data) </li></ul><ul><li>Categories (method blocks bound @ runtime) </li></ul><ul><li>Properties (public instance variables – generate methods) </li></ul><ul><li>Protocols = Interfaces </li></ul>Developed 1985 “ interchangeable software components” Licensed by NeXT 1988 Used by Apple (Cocoa API) Simula C Small Talk C++ Obj-C
    35. 35. Examples
    36. 36. References (Hardware) <ul><li>http://www.apple.com/iphone/specs.html </li></ul><ul><li>http://dev.emcelettronica.com/touch-screen </li></ul><ul><li>http://www.embeddedstar.com/weblog/2007/12/05/st-lis331dl-lis331al/ </li></ul><ul><li>http://www.embedded.com/shared/printableArticle.jhtml?articleID=15200241 </li></ul><ul><li>http://www.arm.com/products/CPUs/ARM1176.html </li></ul><ul><li>Lewin, Peter, May 2006, Cortex-R4: A comparison with the ARM9E processor family </li></ul><ul><li>http://www.imgtec.com/powervr/mbx.asp </li></ul><ul><li>http://www.techonline.com/product/underthehood/209000013 </li></ul><ul><li>http://insidetronics.blogspot.com/ </li></ul><ul><li>http://toucharcade.com/2008/07/07/under-the-hood-the-iphones-gaming-mettle/ </li></ul><ul><li>http://reviews.cnet.com/8301-19512_7-10115256-233.html </li></ul><ul><li>http://www.eetimes.com/news/semi/showArticle.jhtml?articleID=200900740 </li></ul>
    37. 37. References (OS) <ul><li>Silberschatz, Abraham, Greg Gagne, Peter Galvin; Operating System Concepts: 7 th ; John Wiley & Sons 2005 </li></ul><ul><li>http://www.macworld.co.uk/ipod-itunes/news/index.cfm?newsid=16927 </li></ul><ul><li>http://www.macworld.com/article/133867/2008/06/backgroundprocesses.html </li></ul><ul><li>http://en.wikipedia.org/wiki/Darwin_(operating_system) </li></ul><ul><li>http://osxbook.com/book/bonus/ancient/whatismacosx//arch_xnu.html </li></ul><ul><li>Singh, Amit; Mac OS X Internals: A Systems Approach ; Addison-Wesley Professional 2006 </li></ul><ul><li>http://developer.apple.com/macosx/coredata.html </li></ul><ul><li>http://www.roughlydrafted.com/RD/RDM.Tech.Q1.07/4B800F78-0F75-455A-9681-F186A4365805.html </li></ul><ul><li>http://codex.cs.yale.edu/avi/os-book/os8/online-dir/b.pdf (http://www.os-book.com) </li></ul><ul><li>Tanenbaum, Andrew S; Can We Make Operating Systems Reliable and Secure? ; IEEE Computer 2006 </li></ul><ul><li>http://www.w3.org/People/Berners-Lee/WorldWideWeb </li></ul><ul><li>http://rome.ro/2006/12/apple-next-merger-birthday.html </li></ul>

    ×