Giter Club home page Giter Club logo

zw2497 / android-orientation-synchronizer Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 146.01 MB

A new kernel synchronization mechanism which should allow multiple processes to block on an orientation event until the emulator is in a particular orientation.

Makefile 0.29% Shell 0.07% C 95.89% Assembly 1.84% C++ 1.33% Objective-C 0.34% Perl 0.14% Awk 0.01% Python 0.05% GDB 0.01% Yacc 0.02% Lex 0.01% UnrealScript 0.01% Gherkin 0.01% XS 0.01% Perl 6 0.01% Roff 0.01% Clojure 0.01% M4 0.01%

android-orientation-synchronizer's Introduction

f18-hmwk3-team18

Data structure

struct orientevt {
	bool status;				/*indicate if event is within range*/
	bool close;				/*indicate if event is destroeyd*/
	unsigned int evt_id;			/*event_id managed by IDR*/
	atomic_t num_proc;			/*number of blocked processes*/
	struct orientation_range *orient;	/*orient range assigned by orientevt_create*/
	wait_queue_head_t blocked_queue;	/*blocked processes attached to this event*/
};

Locks

A IDR lock for orientevt and locks inside add_wait_queue, prepare_to_wait and finish_wait.

Mechanism

set_orientation:Update status in every struct orientevt and if it is active wake up wait queue.

orientevt_create:Create struct orientevt and link orientevt with unique ID by IDR.

orientevt_destroy:Remove corresponding struct orientevt from IDR. After making sure no process is blocked on this event(indicated by num_proc) it will free the space.

orientect_wait:If the event exists, create struct wait_queue and synchronize with orientevt. If event is active or event is destroyed it will leave wait queue. Particularly if event is destroyed, it will return -EFAULT.

Test program

Test process will fork 4 child processes. Two of them follow facing up event while others follow facing down. After TEST_SEC it will close these two events to let child process exit.

Test result

Lock seems work properly because I noticed the syscall order may change sometimes:
1:facing up!
2:facing up!
2:facing up!
1:facing up!
1:facing up!
2:facing up!

android-orientation-synchronizer's People

Contributors

kuroiiwa avatar matthewachan avatar zw2497 avatar

Stargazers

deger avatar

Watchers

James Cloos avatar

Forkers

kuroiiwa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.