Development of exaggerated platform software (middleware) on mobile operating systems

Source: Internet
Author: User

ArticleFrom csdn lidp http://blog.csdn.net/perfectpdl reprinted to indicate the source.

Mobile Platforms are currently popular: WP7, Mac OS, Symbian, and Android.

From the perspective of the underlying operating system, there are actually only two types: Windows and UNIX. Except for Windows systems, WP7 is built on Unix-like systems. The so-called Unix-like systems refer to FreeBSD, OpenBSD, sun's Solaris and several systems similar to traditional UNIX, such as minix, Linux, and QNX. Although some of them are private software, they all inherit the features of the original UNIX to a considerable extent, there are many similarities, and all comply with POSIX standards to a certain extent.

WP7 is Microsoft's smart mobile operating system, and the development library should be similar to the development interface in windows.
Mac OS is also built on the Unix BSD branch, and Android is built on the Linux operating system.

Others such as Symbian and Palm OS will gradually fade out of sight.
Therefore, we need to write platforms (middleware) on the mobile operating system to concentrate on WP7, Mac OS, and Android.
I personally think that C language development is the first choice. Note the following points:

1. Thread, lock, condition variable, semaphore
Mac OS and Android underlying operating systems are all UNIX-like systems developed and comply with the POSIX standard to a certain extent,
Therefore, the threads on these two systems can be seamlessly transplanted Based on the POSIX thread library, while windows is another.
Usually write exaggerated platform softwareCodeThe macro is used to differentiate, and the following is a exaggerated platform encapsulation for thread creation:

Int tiny_thread_create (void ** tid, void * (* Start) (void *), void * Arg) {# If _ windows1_dword threadid; * (handle *) tid) = createthread (null, 0, (lpthread_start_routine) Start, ARG, 0, & threadid); return * (handle *) tid )? 0:-1; # else * tid = calloc (1, sizeof (pthread_t); Return pthread_create (pthread_t *) * tid, 0, start, ARG); # endif}

2. Socket Library
Although the windows network library was initially developed by BSD socket, its interface is very different from the Unix-like operating system interface developed by BSD socket. Therefore, socket programming should also distinguish between the windows camp and the Unix-like camp.

For example, the multiplexing function poll is wsapol in windows, and poll in Unix-like systems.

3. Time
Note the implementation of gettimeofday and epoch on different platforms.

4. String operations
Using the string operations provided by the C standard library, you can use several stable interfaces (such as va_list, va_arg, and va_copy) to encapsulate them without stack overflow.
The following is a exaggerated platform interface for several string operation functions.
// Use the underlined function in Windows

 
# If defined (_ msc_ver) # define snprintf_snprintf # define vsnprintf_vsnprintf # define strdup_strdup # define stricmp_stricmp # define strnicmp_strnicmp

Pay attention to some non-thread-safe functions (such as strtok and gethostbyname)

Finally, the above summary is not comprehensive, and there are some details, such as poll is not implemented in BSD operating systems,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.