03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

copy to use a suitable, different, address. Potentially, there might need to be a separate<br />

copy of the DLL for each process that uses it. Again, Symbian chose not to implement this<br />

solution because it is contrary to the principles on which Symbian OS is based. In devices<br />

that have relatively small amounts of RAM, it doesn't make sense to have multiple RAMbased<br />

copies of code that was written with the intention of being shared. It would also have<br />

the effect of increasing the ROM size, since each DLL would have to contain the relocation<br />

data that is currently removed as part of the process of building a ROM.<br />

Even if future versions of Symbian OS were to ease the restriction, writable static data<br />

should be used sparingly. To see why, consider that a Symbian OS ROM usually contains<br />

about 100 DLLs, and a typical application will use about 60 of them. Let's assume that each<br />

DLL contains just one word of writable static data. There could easily be 20 applications<br />

running concurrently, and there are about ten system servers working on behalf of these<br />

applications. Given that the smallest reasonable unit of memory allocation in MMUs is 4 k, it<br />

would require a minimum of 4 k × (20 application processes + 10 server processes) × 60<br />

DLLs each = 7 MB of RAM just to hold the writable static data! Using writable static isn't<br />

environment-friendly. Don't do it without being aware of the consequences.<br />

As an alternative to packaging ported code in a .exe, Symbian OS associates a single<br />

machine word of writable static per thread with each DLL. This is thread-local storage or<br />

TLS. You can use the TLS word as an anchor for what would have been your writable static.<br />

There are no MMU granularities to worry about here – just a small performance implication,<br />

since getting the TLS pointer involves a system call which takes perhaps 20 or so<br />

instructions, rather than the single instruction required to get a normal pointer. Not all DLLs<br />

use TLS, but the system allocates the word anyway. In the scenario given above, TLS would<br />

account for only 1.8 Kb – which is perfectly acceptable.<br />

2.10 Files<br />

Let's summarize what we've already seen about files.<br />

Symbian OS phones have no hard disk, as found on PCs. But Symbian OS always has two<br />

disks present, and may have more.<br />

C: System Flash, or RAM, disk – full read/write file system.Contents are initialized to<br />

empty on a cold boot. Data is maintained as long as there is power to refresh the<br />

RAM. Data is recovered in a warm boot, unless it has been corrupted beyond<br />

recovery. Files can be extended indefinitely so long as there are RAM pages to<br />

allocate to them from the system free list. RAM pages are subdivided into 512 byte<br />

sectors, so that small files are managed more efficiently.<br />

Z: ROM – read-only file system. Contents are built by the Symbian OS OEM when<br />

building the device. Some machines, such as the Psion netBook or Series 5MX Pro,<br />

load a ROM image on cold boot so that 'ROM' can be updated and replaced by<br />

enterprise IS departments, distributors and so on.<br />

D: Memory card – removable read/write media, supported by some Symbian OS<br />

phones.<br />

Careful power management is used by the Symbian OS memory-card file system to<br />

ensure that 512 byte sector writes are atomic – they either complete fully, or don't<br />

even start. File formats such as those used by the persistent file store are written<br />

and extensively tested to assume and support, atomic sector writing. These files can<br />

be recovered if failure occurs on any sector write.<br />

Memory cards are slower than the RAM disk, but their nonvolatility and higher<br />

capacity – 20 to 200 MB or so – makes them attractive. Memory cards are an

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!