About S60 Platform: Multiple Threads Example v1.1
--------------------
The Thread Example is an example program that demonstrates thread usage and
synchronization. The example is based on the document Symbian OS: Threads Programming.
Prerequisites
------------
- Active Objects
- Multitasking
- Symbian OS key concepts
Running the Thread Example
----------------------
Open the options menu. Select "Start threads."
Now you should see three animations running.
Open the options menu again and start killing threads.
After killing a thread, the thread should reactivate in a
few seconds, that is, the animation should reappear.
All threads are counting while they are running.
Thread2 and thread3 are synchronized and they increment the same
TInt counter. Thread1 increments a separate counter by itself,
thus no synchronization is required. Threads print the value
of the counter on the screen when they have been killed.
The user can be sure that the thread is running if the value
of the counter is bigger than zero. The counter of Thread1 is reset
when thread1 is killed. The counter of Thread2 & thread3 is reset
when thread2 or thread3 has been killed.
Installation instructions
-----------------------
-----------------------
DEVICE
------------------
S60 2nd Edition SDKs:
Go to /ThreadExample/group
bldmake bldfiles
abld build armi urel
Go to /ThreadExample/sis
makesis Series60_v2x_thread.pkg
Install the .sis file to your device
S60 3rd Edition SDK:
Go to /ThreadExample/group
bldmake bldfiles
abld build [armv5 | gcce] urel
go to /ThreadExample/sis
makesis [Series60_v30_thread_armv5.pkg | Series60_v30_thread_gcce.pkg]
Sign the SIS package with the signsis utility
- See the SDK Help for information about self-signed .sis packages, or
www.symbiansigned.com for information about Developer Certificates.
install the .sis file to your device
EMULATOR
------------------
WINS:
Go to /ThreadExample/group
bldmake bldfiles
abld build wins udeb
Start the emulator
Note! Visual Studio .NET IDE does not compile the .mbm file. Use the abld
build from the command line.
WINSCW:
Go to /ThreadExample/group
bldmake bldfiles
abld build winscw udeb
Start the emulator
It is possible to create a project for CodeWarrior IDE by running the following command:
abld makefile cw_ide
In addition, it is possible to create a project from CodeWarrior IDE:
Open CodeWarrior IDE
Select File -> Import from .mmp file
Browse to /ThreadExample/group folder and select [Thread_s60_3rd_ed.mmp | Thread_s60_2nd_ed.mmp]
Select Project -> Make
Select Project -> Run
After successful build, the application can be found and started from
Applications > Installed > Thread
Known Issues
-------------
NOTE concerning 3rd Edition: When creating a project from the .mmp file, the .mbm building tool is not invoked.
Use the abld build from command line once to get the necessary .mbm file.
Notes on porting to S60 3rd Edition
-----------------------------------
A new .mmp file (Thread_s60_3rd_ed.mmp) + Thread_reg.rss + .pkg files for
3rd Edition (both for armv5 and gcce) created. [The .mmp and .pkg files for 2nd Edition also renamed for clarity.]
icons_aif.mk and thread_loc.rss created.
EKA2 definition (for selecting the right .mmp) into the bld.inf file added.
Changes to the .mmp file:
Target changed from .app to .exe.
Resource definitions changed.
VendorID 0x0 added.
ReadUserData capability added.
Changes to the source code:
thread.cpp:
E32Main function added (application started from eikstart.h) + conditional compiling
macros to support both S60 3rd Edition and previous platforms.
richtexteditorrte.cpp:
Method SetContainerWindowL(aView) (derived from CCoeControl) added into the 2nd phase constructor.
threadappui:
BaseConstructL(EAknEnableSkin) added into the 2nd phase constructor to ensure skin support.
desctructors in various source files:
Nulling/zeroing of deleted objects removed.
Compatibility
-------------
(S60 1st Edition)
S60 2nd Edition
S60 3rd Edition
Tested with Nokia 6600, Nokia 6630, and Nokia E60.
Version history
---------------
1.0 Original example
1.1 Support for S60 3rd Edition added
Evaluate This Resource
--------------------------------
Please spare a moment to help us improve documentation quality and recognize the
resources you find most valuable, by rating this resource at
http://www.forum.nokia.com/main/1%2C%2C90%2C00.html?surveyId=db839245-80fb-4a77-8e9a-35d1568310c3/S60_Platform_Multiple_Threads_Example_v1_1.zip
symiban 多线程 实例代码
需积分: 0 80 浏览量
更新于2009-01-07
收藏 99KB RAR 举报
在Symbian操作系统中,多线程编程是实现并发处理和优化性能的关键技术。这个压缩包文件包含了关于Symbian平台多线程编程的实例代码,对于开发者来说,这是一个宝贵的参考资料,可以帮助他们深入理解如何在Symbian系统上有效地利用多线程。
Symbian操作系统是一个古老的移动设备操作系统,它在早期智能手机时代被广泛使用。多线程在Symbian中尤其重要,因为这允许应用程序同时执行多个任务,提升用户体验,并且充分利用多核处理器的能力。以下是一些Symbian多线程编程的关键知识点:
1. **线程创建与管理**:在Symbian中,你可以使用 CActive 或 RThread 类来创建和管理线程。CActive 类提供了基于事件的异步处理,而 RThread 类则更接近于传统的线程模型。
2. **线程同步**:为了防止数据竞争和不一致,你需要使用同步机制。Symbian 提供了互斥锁(CMutex)、信号量(CSemaphore)和事件(CEvent)等同步原语。正确使用这些同步工具至关重要,可以避免线程间的冲突。
3. **线程优先级**:Symbian 允许为线程设置优先级,以控制它们在CPU上的调度。但需要注意的是,过多的高优先级线程可能导致调度问题,因此合理设置线程优先级是必要的。
4. **线程局部存储(TLS)**:线程局部存储允许每个线程拥有独立的数据副本,这对于避免线程间共享数据的复杂性很有帮助。在Symbian中,你可以使用 TThread::CreateLocal 函数来创建线程局部变量。
5. **线程通信**:线程间的通信可以通过消息队列(CActive::RunL,CActive::DoCancel)或信号量来实现。消息队列是异步处理的基础,而信号量则用于线程间的同步等待。
6. **异常处理**:Symbian中的线程需要考虑异常处理,确保在发生错误时能正确地清理资源。异常处理通常涉及到 CTrapCleanup 类和 TRY/EXCEPT 语句。
7. **内存管理**:由于Symbian对内存管理有其独特的要求,线程需要特别注意内存分配和释放,避免内存泄漏和资源耗尽。
8. **性能优化**:多线程并不总是带来性能提升,特别是在切换开销较大的情况下。因此,了解何时并行化任务,以及如何有效地划分工作负载,是提高性能的关键。
这个压缩包中的源码很可能包含了这些概念的实际应用,通过阅读和分析这些代码,你可以看到如何在实际项目中实现和调优Symbian的多线程功能。`ReleaseNotes.htm` 和 `ReleaseNotes.txt` 可能包含关于代码的详细信息和版本历史,`Licence.txt` 是许可证文件,说明了代码的使用条款。`group`、`sis`、`inc`、`bitmap`、`src` 和 `aif` 文件夹可能分别包含项目的资源、配置信息、头文件、位图资源、源代码和音频文件。
学习和理解这些代码实例,不仅能够提升你的Symbian开发技能,还能让你对多线程编程有更深的理解,这对任何平台的并发编程都大有裨益。
jimmy1qazzaq1
- 粉丝: 0
- 资源: 2
最新资源
- 基于SYSWELD的焊接工艺参数对多道焊焊接残余应力的影响.pdf
- 基于TRIZ冲突解决原理的焊接工艺创新方法研究.pdf
- 基于T型管焊接数控焊枪运动方法的研究.pdf
- 基于VisualProlog的焊接专家系统外壳的研究 - .pdf
- 基于VBA的焊接工艺CAPP系统.pdf
- 基于白车身装配焊接的零件防错设计研究.pdf
- 基于Witness轿车焊接生产线仿真研究 - .pdf
- 基于材料流动轨迹的搅拌摩擦焊接晶粒及焊接区大小预测模型.pdf
- 基于大离焦模式的Nd:YAG激光-MAG复合热源焊接工艺 - .pdf
- 基于纯氩保护气体的304不锈钢激光-CMT电弧复合热源焊接试验研究 - .pdf
- 基于成组技术的锅炉焊接工艺编制研究.pdf
- 基于单片机的全位置自动焊接装置及焊速控制.pdf
- 基于单层神经元的移动焊接机器人焊缝跟踪方法研究 - .pdf
- 基于单目视觉的汽车钣金零件焊接系统设计.pdf
- 基于断裂力学的焊接接头缺陷评定及规范.pdf
- 基于等效结构应力法的正弦波纹腹板焊接梁疲劳评定研究.pdf