QNX Momentics.Основы применения
 5941574304

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

1. Neutrino

QNX — ! (

Э

)

, QNX,

UNIX:

, QNX Momentics ;

,

QNX

Neutrino

Photon microGUI ; QNX Neutrino, .

1.1. И

я

я QNX Momentics QNX Momentics , .

-

,

, -

щ

1.1.1.

.

я QNX Momentics,

.

, Momentics -

: Solaris (

SPARC-

Windows XP (

); 86-

);

RedHat Linux (

86-

);

QNX Neutrino (

86-

).

— QNX Momentics.

,

QNX Momentics ,

QNX Neutrino StrongARM

— ARM ( PowerPC, SH-4

XScale), MIPS,

x86.

(

-

— self-hosted,

Neutrino-hosted)

,

. , QNX ,

-

я

1.1.2. (Neutrino-hosted) QNX

, —

2

QNX Momentics

— ,

Э

.

. " ") QSS QNX. QSS (http://www.qnx.com). QNX Momentics Professional Edition QNX Neutrino :

(

Э

,

Momentics,

Pentium III 700

(

Pentium 4

); —

256

(

512 —

1,5

,

(IDE, Integrated Java. QNX Neutrino SDK

Development Environment),

.

); .

IDE, . QNX Neutrino :

1.

QNX.

2.

.

3.

, QNX Neutrino — QNX Neutrino SDK.

4.

.

5.

GNU-

.

Пр и еча ие Neutrino c (Neutrino hosted) —

, — QNX QNX Momentics Professional Edition ver. 6.3.0 12 2004 . К , , ,

.

,

QNX Neutrino. Пр и еча ие Э

-

,

-

instflop.dat, .

UNIX:

dd if=instflop.dat of=/dev/fd0 Windows

,

rawrite.

EIDE ,

:

Please select a boot option. Option F2 is great for testing QNX compatibility on new hardware without writing anything to the hard disk. It can also be used for system recovery. F2 — Run from CD (Hard Disk filesystems mounted under /fs) F3 — Install QNX to a new disk partition Select? (

,

,

.

QNX . Э

-

.



/fs); QNX



(

.

?)

,

QNX

-

.

. QNX

. .

:

This installation will create a QNX partition on your hard disk and create a bootable QNX Neutrino image. You may abort this installation at any prompt by pressing the F12 key. Press F1 to continue. Press F2 to set verbose (debug) mode. Choice (F1, F2)? ( QNX. .

). (, )?)

(

.



.

,

. (license key),

, -

:

Please enter your license key:

А

. , :

** Invalid or expired license key entered. **

, — . F1 - accept ( —

:

F2 - reject ; —

)

, Э

, -

-

QNX

. .

, :

Please enter the disk your would like to install QNX Neutrino on. The disk must be bootable from your BIOS. ( , Neutrino. Э

,

,

QNX

Э

BIOS

.)

. К , .

Э

,



.

:

*** WARNING*** You have a disk which is greater than 8.4 Gigabytes. The original BIOS calls to access the disk are unable to read data above 8.4G. If your BIOS is older then 1998 you may be forced to choose option 2. Newer BIOSes support on extended disk read calls which can access the entice drive. F1 Allow the QNX partition to be anywhere on the disk. F2 Keep the QNX partition below 8.4G. Choice (F1, F2)? (

8,4 , BIOS .

BIOS, 8,4 1998

.

,

. , BIOS

, . — —

QNX QNX (, )?)

; 8,4

,

.

1998

☺.

, . . Э , QNX Neutrino 6.2.1B:

,

You already have a QNX partition (type 97). You may delete it, in which case all files will be lost. If you choose not to delete the partition, the installation will be aborted because QNX uses this partition type.

F1 Abort

F2 Delete Э

(

QNX. ,



97.

, ,

QNX

. )

(

,

,

).

, .

:

Your disk has room for a 9766 megabyte QNX partition? Please select the size of the partition you would like to create for QNX Neutrino. F1 all 9766 M F2 half 4883 M F3 quarter 2441 M F4 eighth 1220 M F5 Display partition table, so you can delete an existing partition. (

9766

QNX.

,

QNX Neutrino.



— .)

9766 4883 2441 1220 ,

,

QNX ,

. —

Neutrino,

, . QNX

:

You have more then one partition on your hard disk. You need a special partition boot loader to let you choose which partition to load when you boot. Your choices are: F1 Install the QNX partition boot loader. When you boot, it will prompt you to select which partition (OS) to boot. If your partition may start above 8.4G, we recommend this choice.

F2 Install the QNX partition boot loader for machines with old BIOS (before 1996/1997). It should not be used with drives greater then 8.4 G. F3 Use your existing boot loader, which may already provide this capability. Examples include System Commander or LILO. If it does not provide this capability you will be able to boot only the currently set active partition. If your partition starts above 8.4G, this existing loader will need to use the new extended BIOS disk calls. Choice (F1, F2, F3)? .Ч

(

, .

, : "



" ( . . 8,4 , " " 1996–1997 8,4 .

— ( —

QNX. )

.

QNX ;

QNX

BIOS

). . QNX System Commander ,

,

"

"

LILO. , .

QNX

8,4 BIOS

, .

(, , )?)

QNX, ,



. .

, .

.

, , .

,

(

,

Э

,

-

QNX). .

( :

QNX) —

,

Restarting driver and mounting filesystems ... Copying files to the new QNX partition. Please wait ... (

... QNX.

,

…)

,

:

100% Copying core files to hard disk 100% COPY /cd/boot/fs/qnxbase.ifs to 100% COPY /cd/boot/fs/qnxbase.ifs to 100% COPY /cd/boot/fs/qnxbasedma.ifs 100% COPY /cd/boot/fs/qnxbasedma.ifs 100% COPY /cd/boot/fs/qnxbasesmp.ifs Recording licenses … complete

/hdisk/boot/fs /hdisk/.altboot to /hdisk/boot/fs to /hdisk/.boot to /hdisk/boot/fs

,

QNX Neutrino, ,

(core files) , qfs-

. :

QNX Momentics 6.3.0 Development Seat Installation --------------------------------------------------Throughout installation, you will be prompted for necessary information. The default answers are displayed in brackets after the question. If you press the key, the default answer will be used. After typing your answer, press the key to continue the installation. ( QNX Momentics 6.3.0 ---------------------------------------------------------------------------------. . .

,

.)

: Do you wish to install to the default location of `/usr/qnx6301` (y/n)? [y] ( /usr/qnx630 ( /

(

)? [ ])

).

Do you wish to install the QNX Neutrino SDK (All Targets) (y/n)? [y]

,

( ( /

QNX Neutrino SDK (

)

)? [ ])

, CD-ROM ,

.

— -

, CD-ROM,

:

/fs/cd0/install

, .

QNX Neutrino SDK . Пр и еча ие

К , QNX Neutrino SDK — Momentics Standard Edition.

,

QNX

: Do you wish to install the Integrated Development Environment (y/n)? [y] (

( /

К

, ,

IDE

Edition (

)? [ ])

! Standard

Professional Edition ). ,

,

GNU tar

, GNU GPL (General Public License, GNU1), GNU sed:

Do you wish to install the GNU Public License Utility package (y/n)? [y] (

, GNU GPL ( /

( GPL

)? [ ])

). .

,

, :

1

А

: "GNU's Not Unix" — "GNU — UNIX".

Installing Installing Installing Installing

qnx-host ... please wait. qnx-target ... please wait. qnx-qde ... please wait. qnx-target-gpl ... please wait.

, ,

, CD-ROM

Э

:

** Installation complete ** Please remove the installation media then press 'Enter' to reboot

CD-ROM QNX Neutrino

1.1.3.

я

я

-

. .

QNX Neutrino Э

,

QNX Neutrino, ( ,

. , .)

Press F1-F4 1,2,3,4? 1 (

for

QNX Neutrino , select

drive

, , 1, 2, 3 4? 1)

or

select

QNX : partition



,

. ,

QNX

:

/.boot,

/.altboot.



: Hit Esc for .altboot

, -

. ,

QNX Neutrino

diskboot,



:

Press the space bar to input boot options or D to disable DMA... (

< DMA1)

>

,

, .




: F1 Safe modes F5 Start a debug shell after mounting filesystems F6 Be Verbose F7 Mount read-only partitions read/write if possible F8 Enable a previous package configuration F9 Target output to debug device defined in startup code F10 Force a partition install F11 Enumerator disables F12 Driver disables Enter Continue boot process Please select one or more options via functional keys. Selection? ( — — ; — —

"

";

; ,

; — — startup; — — — — ,

; , ; ; ; . ,

, .

?)

1

DMA — Direct Memory Access (

,

).

. diskboot,



, QNX (

-

).

,



. , .

, diskboot , ,

,

diskboot

( . . "

QNX .

"). diskboot

/.diskroot. /.diskroot,

, :

You have more then one .diskroot file which wants to mount at / F1 /dev/hd0t78 F2 /dev/hd0t79 Which one do you wish to mount?

Э Neutrino 6.2.1A, .

QNX

/dev/hd0t78 biskboot /dev/hd0t79

. /, /fs (

-

/dev/hd0t78

!). diskboot /etc/system/sysinit, /etc/rc.d (

,

/etc/rc.d/rc.local).

, ,

( /etc/rc.d/rc.setup-once):

Generating helpviewer search index ( )

К

,

/etc/system/setupisdone,

/etc/rc.d/rc.setup-once

, .

rc.setup-once

(

) . : ; ; ; .

К

,

— Photon microGUI (

).

, .

, (

Test .К

)— ,

Continue (

).

,

15 . . QNX

. — ,



.Э . !)

(

☺. Э

root

, QNX Neutrino. .

1.1.4. И

я

я

я QNX Neutrino,

,

, .

QNX Software Installer (qnxinstall) ( Launch.

. 1.1.

. 1.1),

QNX Software Installer

-

,

Э

— (http://www.qnx.com)

.

QSS

QNX Neutrino. , Find Web Repositories.

File QSS .

, . — 3rd-Party Software, . ,

QSS1. Щ . AbiWord (x86)

Install (

. 1.2.

. 1.2).

AbiWord (

x86)

— Status

New

,

. .

, ,

/

. . , . ,

(Status)

Э 3d Party Software".

1

New

Active.

-

"QNX Momentics

1.2. К , , .

я

1.2.1.

я

,

( ,

) —

.

,

,

,

QNX Neutrino ( . .

(

.

).

Photon), nophoton.

/etc/system/config

,

nophoton.

,

— Photon. -

, (

,

,

),

root

shell. Э

(login shell).

Пр и еча ие . 1.3.1.

, Photon ). К

ph

,

Photon :

?

,



LOGNAME. LOGNAME

login,

Photon,

,

(

. ,

LOGNAME



.

LOGNAME

Photon

-

. :

— (

Log out

Launch

phshutdown);

login shell —

exit;

logout shutdown.

shutdown root).

(

") –f ( . . fast — "

shutdown

SIGPWR (" , . "),

. shutdown, –S: system —

;

reboot —

;

photon —

Photon

"

";

user —

. . /var/log/wtmp,

shutdown

. phshutdown shutdown.

SIGPWR

,

. Ч ,

, root, /usr/photon/config/phshutdown.restrict. /var/log/wtmp, phshutdown

. , phshutdown : Photon;

. К

,

QNX . ,

,

, Power;

QNX " -ATX-

"

,

. ,

, . (workspace) Photon. К . Launch. ,



, Launch

. — Shelf ("

. 1.3.

",

. 1.3).

Shelf

"

"

: Photon

Terminal

(pterm) —

, ;

Helpviewer — .

,

Photon File Manager (pfm) — "

" ,

(

QNX ; . Norton Commander mqc (MiShell QNX Commander), , " " 3rd-Party

Software).

1.2.2. К . —

Э

, , IP, .

IP. , ,

IP, . , Network

, Configure (Manual) IPTCP/IP Configuration (

. 1.4.

(

Shelf)

. 1.4).

IP-

,

QNX Neutrino DHCP1-

.

, DHCP. К , DHCP-

QNX dhcpd Utilities Reference).

Neutrino (

Э (Host Name) (Default Gateway)

Network (Domain Name), IP(Name Servers) ( . 1.5).

. 1.5.

К

, IP-

,

DNS-

,

(

— myname), TCP/IP,

Qnet

QNX — Qnet. .

,

IP, Click here to toggle the display of advanced options such as network routing.

1.2.3. QNX

,

-

: 1

DHCP (Dynamic Host Configuration Protocol) — .

.К .

, ,

Photon microGUI; pterm;

("

"). Photon microGUI , , . " Configure User's Configuration.

Unicode, . "( . . 1.3) Localization. ,

.

Language

) А

— Keyboard.

Russian. Done (

. Apply (

).

" User's Configuration , ,

". ,

,

. А :

/etc/system/trap/.KEYBOARD.myname : myname — )

,

(

:

en_US_101.kbd ru_RU_102.kbd

,

,

(.). Э

, ,

,

. Ч Photon,

Preferences Edit Hide 'dot' Files ( ) ( . 1.6).

. 1.6.

Preferences

,

pfm

Photon , + (

)).

(

.

(

"

)

", ,

. SWD Cyrillic Pack, ,

.

1.2.4. Photon

microGUI,

,

, ,

Launch —

Configure.

,

. , QNX Neutrino,

(

/etc/rc.d/rc.local, root):

touch /etc/rc.d/rc.local chmod 744 /etc/rc.d/rc.local

, ,

Neutrino. inetd.

,

Пр и еча ие . 1.3.1.

, Photon, "

"

$HOME/.ph/phapps

:

touch ~/.ph/phapps chmod 744 ~/.ph/phapps

.

Э .

,

, Photon microGUI ,

Пр и еча ие phapps,

rc.local, .

Э

, "

.

- "(

"

") (

).

, "

",

pfm

,

Open, View Open

,

( . 1.7.

. , Associations . 1.7).

Edit. . .

Edit —

-

, -

.

Add. (

. 1.8)

.

. 1.8. А

PDF-

:

xpdf

,

Pattern ( " " (

) — "|").

,

Done ( ,

!).

Пр и еча ие XPDF,

xpdf 3rd-Party Software. XPhoton К , XPhoton

1.3.

QNX Neutrino —

,

Э

XPhoton phapps.

,

,

,

.

. ,

,

, .

Neutrino



.

. ,

POSIX.2 Neutrino

-

. .

1.3.1. К

я "

",

. Photon

pterm. К

(

"

"



$,

— #). . (

,

) .

exit (

Ч

я

"

,

).

"?

К



.

: Bourne Shell (sh) — POSIX 1003.2;

,

Korn Shell (ksh) — Bourne

sh;

Again sh;

Shell

(bash) —

C-Shell (csh) — .

"

(

"-

.) Linux, QNX — ksh.

,

bash, ksh

sh,

,



,

QNX

,

/bin/sh —

/bin/ksh.

. ,

ksh

QNX

"

— " "

"

. :

esh —

(Embedded Shell). ksh, /etc/esh. Э . .;

uesh —

(Micro-embedded

Shell),

esh;

fesh — "

"

shell). Э

(Fat embedded esh. ,

uesh, fesh

shell ,

"

,

esh

"

uesh.

, pwd

,

. .

/(

. )

#

: # pwd /root

, (/root). Пр и еча ие QNX UNIX-

К

, "root".

(



) . ,

, /tmp:

cd /tmp

,

,

.



, (

"root". ,

. . /,

Neutrino

,

щ

) . .

Э

, :

cd tmp

,

/root/tmp. Ч

,

. Ч /),

cd

( . . : cd ..

,

,

/tmp/myfilder.

/tmp,

: mkdir myfolder

Пр и еча ие К



,

(



)?

, PATH. , PATH, .

: echo $PATH

.

set

myfile.

/tmp

: touch myfolder/myfile

: cd myfolder touch myfile

: touch /tmp/myfolder/myfile /usr/bin: ls /usr/bin

/etc/services, /tmp/myfilder/myfile_2: cp /etc/services /tmp/myfolder/myfile_2 /tmp/myfolder/myfile_3:

/tmp/myfolder/myfile_2 mv /tmp/myfolder/myfile_2

/tmp/myfolder/myfile_3 /tmp/myfolder/myfile_3:

cat /tmp/myfolder/myfile_3

? "

,

" ( . 1.3.1):

/

cat /tmp/myfolder/myfile_3 | more

, ,
(



).

/tmp/myfolder/myfile: rm /tmp/myfolder/myfile /tmp/myfolder: rmdir /tmp/myfolder

Ч ,

? К ,

,

rmdir

/tmp/myfolder,

,

myfile_3.

: rm –R /tmp/myfolder

,

. , Utilities Reference. ( , , ls –l (

, ,

Helpviewer ) .

. long —

) (

,

) :

"

"

,

ls –l /etc/rc.d

( , ped (Photon Editor). (

ASCII.

,

,

) Photon

(

. .), .

vi vi —

. 1.3.2). .

я , (

),

"

shell. К . .

"

cd, pwd, set, echo, alias

, (;).

, ,

(\). Ч ,

(

)

(&).

,

ped —

Photon :

ped &

. , ped

, + , bg.

,

, fg.

,

, -

,

wait.

PID1

wait

,

,

, ,

wait

shell. , POSIX1

Process ID —

+ , kill QNX-

— slay.

.

PID

kill slay —

, .

,

,

POSIX-

ps,

QNX-

pidin.

sin

shell

&&

,



.

:

mkdir /tmp/myfolder2 && touch /tmp/myfolder2/myfile2 /tmp/myfolder2, ( myfile2.txt. ||,

)

,

shell ,



.

:

mkdir /tmp/myfolder2 || rm /tmp/* /tmp/myfolder2, ,

,— /tmp.

/ "

" /

0—

.

К :

(stdin);

1—

(stdout);

2—

(stderr), "

".

Э

, ++, ,

1

. 2—

0 .

,

:

sin fd

К , >.

. . :

-

.

ls /usr > /tmp/file1

К

ls

/usr

,

,

/tmp/file1.

,

. ,

/tmp/file1

. : pwd > /tmp/file1

К

pwd /tmp/file1,

.А ? >>, . .

: pwd >> /tmp/file1 pwd /tmp/file1. /tmp/errlog

, "

"

ls /tmp11 2>/dev/null

,

:

,

>&.

, . (/tmp/file1) (/tmp/file2),

/tmp/log:

cat /tmp/file1 /tmp/file2 > /tmp/log

, ,

:

cat /tmp/file1 /tmp/file2 > /tmp/log 2>&1

2

1.

: wc -с /tmp/file2 /tmp/file1,

wc /tmp/file2.

.

К

,

, :

| ls –l /usr/bin | wc -l

,

ls /usr/bin,

"

"

wc,

ls.

"

"

,

,

(

— ,

wc).

,

, .

,

:

ls /usr/bin | sort | wc -l > /tmp/file2 tee,

.

, —

,

,

:

ls — l /usr | tee /tmp/lslog

,

tee

, — /tmp/lslog).

(

, QNX

, " /

.

"

"

"

, , ,

. ,

"Hello folks!"

pterm.

tty.

pterm

, /dev/ttyp1.

pterm pterm

:

echo Hello folks! > /dev/ttyp1

:

/tmp/file1 cat >/tmp/file1 < /dev/null

,

-"

"

(`). Пр и еча ие К



('), .

: less `which ph`

К

,

which PATH ( . . shell),

"

,



. К ,

"

less

, ( ). ph,

< ,

.

,

,

/ .

>,

,

Э , .



,

, . Shell

. : /bin,

, .

Пр и еча ие 4.

,

, QNX. find:

find /bin –type l

К

cksum.



, find:

cksum `find /bin –type l`

,

,

awk. cksum

awk

,

, — result.txt.

( (

),

).

cksum `find /bin –type l` | awk ‘{print $3 “\t” $1}’ > \ /tmp/result.txt

К

,

POSIX.

1.3.2 И

vi : vi

vi я_фа

а

я_фа

а.

,

. :

; . . (input)

(add).

:

, —

, . .

,

.

vi ,

.

,

,

vi ,

. 1.1. Та

и а 1.1.

vi

К i

(insert)

a

(add)

yy {n}yy

,

n

,

dd {n}dd

n

,

,

p x G {n}G

n ша

/ша n :w :w фа

фа

("C

…")

:q :q! vi

, QNX elvis; vi — ,

vi,

( 4).

.

vi —

IMprovement).

vim

(

Vi

vim —

( :syntax on).

1.3.3. я , ++. ,

,

,

++. .

щ

("

") —

.

, :



. Э

— qcc.

, , (

. ,

/etc/qcc).

"Hello, world!". :

hello.c main() { printf("Hello, world!\n"); }

, #include — qcc stdio.h .

" Intel-

hello

, qcc –Vgcc_ntox86 hello.c –o hello

, , qcc –V

",

, gcc_ntoppcbe — gcc_ntomipsle — MIPS LittleEndian.

PowerPC BigEndian,

, x86. : qcc hello.c –o hello PATH (

. . 1.3.1),

.

:

./hello

К

"

" (.) —

,

. .

./hello

.

hello

Пр и еча ие ,

PATH "

" : PATH=.:$PATH А

$HOME/.profile, .

QNX Neutrino 6.3 2.95.2 (

GCC3.3.1. :

)



qcc –V3.3.1,gcc_ntox86 hello.c –o hello_new

1.3.4. У щ

make , main()1

.

, main.c:

#include "defs.h" int main()

1

.

main() — ,

++. , . .

,

. main().

,

.

{ printf("I'm main\n"); aaa(); return 0; }

,

main(), — aaa()

"I'm main", 0.

main.c defs.h1,

aaa(), bbb()

#ifndef #define #ifndef #define #endif _EXT void aaa(); _EXT void bbb(); _EXT void ccc(); #endif

_MY_DEFS_ _MY_DEFS_ _EXT _EXT // _EXT

ccc():

extern

// _MY_DEFS_

Пр и еча ие (

#),

defs.h, defs.h .

К

, defs.h.

aaa()

aaa.c.

bbb():

"I'm aaa" #include"defs.h" void aaa() { 1

,

, ++ ,

– ?

,

( ,

cpp) include,

.



printf("I'm aaa\n"); bbb(); }

bbb()

bbb.c.

ccc():

"I'm bbb" #include"defs.h" void bbb() { printf("I'm bbb\n"); ccc(); }

ccc() —

ccc.c "I'm ccc":

#include"defs.h" void ccc() { printf("I'm ccc\n"); } program,

: qcc qcc qcc qcc qcc

–c –c –c –c –o

main.c aaa.c bbb.c ccc.c program main.o aaa.o bbb.o ccc.o

. ссс.c,

,

program main.c,

.

, ,



,

:

qcc –o program main.o aaa.o bbb.o ccc.o

, , .

К

,

, , , , .

,

Makefile,

make. , makefile,

make

,

,—

Makefile. make

,

, –f.

Пр и еча ие К , make,

. Makefile

— Ц

.



,

.

: Ь: ЗАВ С С Ь-1 ЗАВ С К А А-1 К А А-1 ... К А А-N

С Ь-2 ... ЗАВ С

Ь-i — ЗАВ С С Ь-i —

,

. .

, .

. ,

С Ь-N

. —

Пр и еча ие

К

.

А

.

make

, ,

.

,

make

Makefile,

. ,

.

, make .

,

.

-

( . . " "

"),

".

,

, mf1:

program: main.o aaa.o bbb.o ccc.o qcc -o program main.o aaa.o bbb.o ccc.o main.o : main.c defs.h qcc –c main.c aaa.o : aaa.c defs.h qcc –c aaa.c bbb.o : bbb.c defs.h qcc –c bbb.c ccc.o : ccc.c defs.h qcc –c ccc.c

: make –f mf1

Пр и еча ие ,

(

,

,

.

,

) program :

make

make: 'program' is up to date :

-

,

,

,

.

(make:

program )

defs.h

"

touch defs.h

",

program program:

,

,

,

make

— program.

,

program

. ,

make

.

:

make –f mf1 ссс.o ccc.o, . .

. ,

make

( . . -

,

.o)

make

–c. mf2):

qcc

( program: main.o aaa.o bbb.o ccc.o qcc -o program main.o aaa.o bbb.o ccc.o main.o aaa.o bbb.o ccc.o: defs.h

,

.Ч :

, П

, make

АЯ=З А

З А

, . : $(П mf3):

(

АЯ).

OBJS=main.o aaa.o bbb.o ccc.o program: $(OBJS) qcc -o program $(OBJS) $(OBJS): defs.h

. К : AR=ar —

-

AS=as —

;

CC=cc —

; (сс —

CXX=g++ —

++;

CPP=cpp —

;

qcc);

,

LEX=lex —

-

RM=rm -f —

; . , make:

$@ —

;

$? —

,

,

;

$^ —

;

$* —

.

Пр и еча ие : make –p /dev/null

(

mf4):

OBJS=main.o aaa.o bbb.o ccc.o program: $(OBJS) $(CC) -o $@ $(OBJS) $(OBJS): defs.h

,

, ,

. — clean (

mf5):

OBJS=main.o aaa.o bbb.o ccc.o program: $(OBJS) $(CC) -o $@ $(OBJS) $(OBJS): defs.h clean: $(RM) program $(OBJS)

,

, install. , .

.PHONY,

. OBJS=main.o aaa.o bbb.o ccc.o .PHONY=clean program: $(OBJS)

mf6:

$(CC) -o $@ $(OBJS) $(OBJS): defs.h clean: $(RM) program $(OBJS)

,

,

.

Makefile

. #,



. make

.

1.3.5. Linux man,

UNIX. Man/usr/man.

QNX ,

, . " use.

usage-

" ,

ls:

use ls

Пр и еча ие . use

PATH.

Neutrino usage:

.

usemsg program text program —

,

, text — usage-

,

.

2.

, ...

Э

,

А

С

, QNX Neutrino, . : , QNX Momentics Professional Edition; ; ;

POSIX; .

2.1. И

QNX Momentics QNX Momentics .

,

, , , .

,

,

,

.

я

2.1.1.

, GNU Compiler Collection (GCC). ,

QNX Momentics, ++, .

К

QNX Momentics Java JIT-

Neutrino IBM j9.

2.1.2. К К

QNX Momentics. К

, :

DDK (Driver Development Kit) — Graphics DDK

. .К

"

. : Audio DDK, Network DDK, DDK . " , DDK

, ,—

(

)

; TDK (Technology Development Kits) —

,

,

, , UNIX, Extended

. Networking TDK (Net TDK) IPSec, IPv6, SCTP, SNMP v2, IP Filter, DHCP, DNS . . Symmetric Multiprocessing TDK, 3D Graphics TDK . TDK .К

TDK TDK

(

,

, ,

);

BSP (Board Support Packages) — QNX Neutrino ( ,

Neutrino ).

IPL, Startup , QNX Momentics PE

,

, . IPL, Startup

, . BSP ,

.

IPL

Startup

6; . К

Embedding Tools — . . Э

-

QNX Neutrino, , QNX

,

Momentics; SAT (System Analysis Toolkit) — , . . . .Э ( , Professional Edition). К

,

, QNX Momentics

QNX Momentics

,

(Power management framework), Qnet (Qnet SDK) .

2.1.3. И

я

Launch > QNX Momentics 6.3.0 > Integrated Development Environment , (workbench). QNX IDE workspaсe ( ). , IDE . IDE . :

QNX IDE " Eclipse,

"

Java. Eclipse,

, —

"

" (plug-in), .

(editor) / -

,

,

Makefile.

П

, ,

(

) ,

,

.

,

, (view) .К

, -

, , IDE

(perspective).



Resource

,

, C/C++ Development — Java —

Java-

: / ++;

;

Debug —

;

Plug-in Development —

IDE;

QNX Application Profiler — ; QNX System Builder — QNX

Э

;

QNX System Profiler —

, System Analysis Toolkit;

QNX

System

Information —

, . XML1,

, "

,

". ,

, . ,



.

. 2.1

Debug

. 2.1.

.

Debug

"

Window > Properties, ", :

Perform build automatically on resource modification — ;

1

XML (eXtensible Markup Language) —

.

Save all modified resources automatically prior to manual build — ; Link Navigator selection to active editor — Navigator. — . : , ,

, , ,

. . К , . .

2.1.4.

я QNX Neutrino — IBM Rational

Rose RealTime (

— RoseRT).

IBM Rational Rose UML (Unified Modeling Language — ), ,

, (class diagram),

(use case diagram),

(sequence diagram),

(deployment diagram) ,

, (

"

. .

UML,

" — actors). .

UML . UML

.

"

"

RoseRT ROOM (Realtime Object-Oriented Modeling —

-

). , . : —

( )

, ;



К

,

. , (

)

. ; — ,

. .

,

Э ,

. , .

, .

,



, . . RoseRT

,

. RoseRT )

, ++

QNX Neutrino Rational Rose RealTime Layer. А

Java,

( ++. IBM Windows

, Rational Rose Adaptation www.qnx.com,

QNX Momentics Professional Edition ( myQNX www.qnx.com).

.

IBM Rational Rose RealTime, IBM. , , (

, ).

2.1.5.

я (GUI, Graphic User Interface). ",

"

Photon QNX Momentics. Э .

Application Builder (PhAB),

Windows,

. GUI-

PhAB. PhAB

main()

.

: ; ; -

(callback). PhAB .

С

. Photon. Ч

GUI. PhAB ,

, -

, (

),

.;

Д (

,

. (widget) )

,

, ;

,

П

. . "

,

", "

".

, ,

, Photon



GUI-

. ; ; З

. ,

.

,

PhAB — .

, (tutorial), QNX Momentics.

я

2.1.6.

я

QNX Neutrino (Concurrent Version control System) — . QNX IDE CVS.

CVS Linux-

Пр и еча ие . QNX IDE — Rational ClearCase.

: ,

(repository). К ,

, ,

. . , ,

, . — ,

, .

QNX

CVSCVS(

QNX, —

):

1.

, cvsuser. /var/cvs (

. 4.6.3).

cvsuser:

su - cvsuser

2.

CVSROOT, EDITOR,

,

(

EDITOR vi):

export CVSROOT=/var/cvs export EDITOR=ped

3.

: cvs init /var/cvs CVSROOT.

4.

,

,

/home/myname/myproject

: cd /home/myname/myproject cvs import myproject cbd_bc init myproject —

,

(

), init —

swd —

(

).

, (

vi,

EDITOR

), (CVS

,

,

). ,

.

.

5.

CVS/etc/services cvspserver

: 2401/tcp

/etc/inetd.conf

:

.

-

cvspserver stream tcp nowait root /usr/bin/cvs cvs --allowroot=/var/mycvs pserver

,

.

-allow-root

6.

TCP/IP inetd, .

cvs cvs HOME (

inetd

,

),

:

unset HOME inetd

QNX

CVSCVS. К

CVSROOT. :Ме

: а:

_

ва е



: е

и а и

: export CVSROOT=:pserver:[email protected]:/var/cvs

QNX IDE

— . .

Check Out:

IDE , .

,

,

(

-

IDE

CVS

)

. (

,

— ,

. 2.2). . 2.2.

— ,

,

,

,

,

cvsuser.

, ,

,

QNX-

.

,

,

CVS,

, CVS—

, . . -

cvsuser.

passwd.

/var/cvs/CVSROOT

,

CVSИмя_

:

ва е я_CVS: а иф _ а

CVS-

ва е я_QNX

:Имя_

myself

:

basily

myself::cvsuser basily::cvsuser cvsuser: chown cvsuser /var/cvs/CVSROOT/passwd

CVSCVS-

basily (

myself

,

/etc/shadow (

, ,

,

). .

. 4.6.2). crypt(). crypt(),

,

. cvsuser (

login shell /dev/null —

).

cvsuser cvsuser /etc/shadow

.

,

CVSROOT/passwd

CVS-

, CVS-

CVSROOT/passwd,

.

2.2. У , ,

— QNX.

.

2.2.1. "Ш П

?"



.

, .

( . .

— ). М

( —

,

)

.

,

, ,

,

: (Process ID, PID) —

,

; (Parent PID, PPID) — PID , . . ;

,

(User ID, UID Group ID, GID) —

, (

)

,

.Э (login

shell),

-

login,

Photon, phlogin.

, ( . .

UID

, ,

GID );

(Effective UID, EUID

Effective GID, EGID) — . . .

, , ;



(

), . pwd;

— ,

,

; (umask) — ,

, ;

Пр и еча ие QNX Neutrino

4.

; . Пр и еча ие QNX Neutrino 3.

( )— : (user time — ), (system time — , . .

,

), , . —

main().

, (

process.c):

#include #include int main(int argc, char **argv, char **env) { struct rusage r_usage; printf("\nProcess Informaition:\n"); printf("Process name = \t\t%s\n", argv[0]); printf("User ID = \t\t< %d >\n", getuid()); printf("Effective User ID = \t< %d >\n", geteuid()); printf("Group ID = \t\t< %d >\n", getgid()); printf("Effective Group ID = \t< %d >\n", getegid()); printf("Process Group ID = \t< %d >\n", getpgid(0)); printf("Process ID ( PID )= \t< %d >\n", getpid(0)); printf("Parent PID ( PPID )= \t< %d >\n", getppid(0)); printf("Process priority= \t< %d >\n", getprio(0)); printf("Processor utilisation:\n"); getrusage (RUSAGE_SELF, &r_usage);

printf("\t< user time = %d sec, %d microsec >\n", r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec); printf("\t< system time = %d sec, %d microsec >\n", r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec); return EXIT_SUCCESS; }

: (

.

. 2.2.2); ;

; (

.

. 2.2.3).

2.2.2. " (

А

" procnto),

PID

1.

,

.

: exec() — , ; fork() —

"

"

; Пр и еча ие UNIX—

fork(), exec().

-

fork()

. 3.

vfork() ("

fork()") — fork()-exec().

"

fork(),

, ,

exec();

"

spawn*() —

,

. QNX Neutrino; system() —

shell

, .

,

fork() fork()

,

fork.c.

, —

, : #include #include int main(int argc, char **argv, char **env) { pid_t pid; char *Prefix; Prefix = (char *) malloc (sizeof(char)); pid = fork(); if (pid == 0) sprintf ( Prefix, "CHILD:"); else sprintf ( Prefix, "PARENT:"); printf("%s Process name = %s\n", Prefix, argv[0]); printf("%s PID = %d\n", Prefix, getpid(0)); printf("%s PPID = %d\n", Prefix, getppid(0)); return EXIT_SUCCESS; }

Пр и еча ие —

fork() .

exec.c

vfork()

exec():

#include #include int main(int argc, char **argv, char **env) { pid_t pid; pid = vfork();

if (pid == 0) { execlp("process", "process", NULL); perror("Child"); exit( EXIT_FAILURE); } waitpid(0, NULL, 0); printf("Parants’s PID = %d\n", getpid(0)); printf("Parants’s PPID = %d\n", getppid(0)); return EXIT_SUCCESS; } spawn.c

: #include #include int main(int argc, char **argv, char **env) { spawnl ( P_WAIT, "process", "process", NULL ); printf("Parants’s PID = %d\n", getpid(0)); printf("Parants’s PPID = %d\n", getppid(0)); return EXIT_SUCCESS; }



)

Э

.

main().

2.2.3. З ,

slay

,

kill

,

kill(), sigqueue()

. . "

. . А

"

,

,

. . Э

, .

,

. Э

А

. , ,

exit()

return. Ч exit()

main()

, return,

. , ?: echo $?

Пр и еча ие ,

-

wait*(). , wait()

POSIXwaitpid().

, А

, , "

"—

"

,

wait*(), , ".

А

, . Пр и еча ие -"

К

"

,

"DEAD-

? )

".

wait*() (

,

WAIT.

spawn*() P_NOWAITO. -" .

",

. . А ,

wait*()

.

,

atexit(), -

,

. .

,

. 32 , First Out",

LIFO ("Last In — -

. . ).

2.2.4. Neutrino ps —

: POSIX-

.

QNX ,

POSIX, QNX;

sin —

QNX.

,

sin

, Qnet.

sin — PID,

,

. •

:



args —



env —



flags —



cpu —



fds —



info —



net —



signals —



timers —



memory —



registers —



threads —

; ; ; ; ; ; ,

; ; ; ; ; ,

;

users — .

, sin fl.

sin flags



sin

(

psin

. 2.3). . 2.3.

psin

System Process Inspector

pidin —

QNX

6.

К

, QNX IDE —

QNX System Information. Ч ,

qconn

, , Э . . 2.4.

Information

. 2.4. Summary

. ,

qconn

QNX System

QNX System Information

,

System

(

, . 2.4

System Summary).

я"

2.2.5. " "

" dumper,



). Э

" core-

" core-

( -

coreимя_

е

/var/dumps

а.core. coreinfo,

GNUgdb имя_

. ,

dumper

г аммы имя_

coregdb: г аммы.core

: ,

А

coreIDE,

. .

Пр и еча ие , core-

2.3.

.

я : ; ; ; DLL.

2.3.1.

щ

я pirntf().

Э

stdio.h, libс.a.

printf() .

С

. oar. lib

. a(

, libsocket.a). . ,

Executable and Linking Format), main(). so (

lib

(ELF,

,

, . Shared Object —

),

(

,

libmy.so.2).

: ;

, ; . : ; . , dlopen()

.

dlclose() . QSS, , DLL (Dynamic Link Library — ). , DLL ,

Windows Shared Library .

2.3.2. , (

.

1). Э

"

make defs.h, main.c, aaa.c

"

bbb.c.

Make-

:

static.mf

OBJS = aaa.o bbb.o ccc.o .PHONY=clean libmy.a: clean $(OBJS) ar -q libmy.a $(OBJS) $(OBJS): defs.h clean: $(RM) *.o libmy.a libmy.a,

:

make –f static.mf aaa.o, bbb.o

ccc.o,

ar libmy.a.

:

qcc –o my_static –L ./ main.c -lmy

,

–l

,

–L —

. Пр и еча ие , .a. К my.

lib

–l

я

2.3.3. Make-

shared.mf

: OBJS = aaa.o bbb.o ccc.o CFLAGS+=-shared .PHONY=clean libmy.so: $(OBJS) $(CC) -o $@ -shared $(OBJS) $(OBJS): defs.h clean: $(RM) *.o libmy.so libmy.so,

: make –f shared.mf clean make –f shared.mf

C

aaa.o, bbb.o

ccc.o, -shared. libmy.so.

: qcc –o my_shared –L ./ main.c -Bdynamic –lmy

,

–l

,

–L —

.

-Bdynamic

,



.

Пр и еча ие , .so. К my.

lib

–l

Ч

my_shared,

,

, libmy.so.

:

1. ,

LD_LIBRARY_PATH

. 2. DT_RPATH

.

3.

А .

LD_LIBRARY_PATH

QNX Neutrino ( ,

, , . .

. 6.2).

LD_LIBRARY_PATH

".":

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./my_shared ls -l my_shared libmy.so. my_static libmy.a.

Пр и еча ие ,

DT_RPATH. ld. Ч

–rpath qcc, –Wl,-rpath

ь_к_ аз _ :

, ъ к

qcc .

qcc –o my_shared –L ./ main.c -Bdynamic \ –lmy –Wl,-rpath ./

2.3.4. И

DLL dll.c, libmy.so:

aaa()

#include #include"defs.h" int main() { void *dll; void (*my_funk)(); printf("I'm main\n"); dll = dlopen("libmy.so", RTLD_NOW); if (!dll) { perror("dll"); exit(1); } my_funk=dlsym(dll, "aaa"); (*my_funk)(); return 0; }

Э

. dlopen()

libmy.so.

dlsym()

aaa()

libmy.so.

,

,

aaa().

я

2.4. POSIXQNX "

"

Neutrino, ,

(IPC, InterProcess Communication). , , (

— POSIX-

QNX Neutrino .

) IPC: ; ; POSIX.

К

, .

2.4.1. .

. К

— ,

.

— (

.

pipe

(

1). Э .

,

3) ( pipe).

pipe(), .

, , —

.

К ,

POSIX—

IPC,

. К

, —

,

-"

",

. . , .

И —

POSIXNeutrino. — FIFO ( . 4), . FIFO —

:

mkfifo;

— FIFO —

,

mkfifo(). ,

, ,

,

-

, (open(), read(),

write(), close()

. .),

-

,

, ,

,

(

я

2.4.2.

,

я

).

я

— POSIX-

( )

,

,

. , :

1.

shm_open() ,

2.

.

shm_ctl() .

3.

mmap() , (

,

). 4. —

unmap(), shm_close(),



— shm_creator

shm_user.

shm_unlink(). : 1.

shm_creator,

, ,

.

2.

shm_user,

,

shm_creator,

. . shm_creator.c #include #include #include #include int main()

:

{ int fd, status; void* buffer; fd = shm_open("/swd_es", O_RDWR | O_CREAT, 0777); if( fd == -1 ) { perror("shm_creator"); return EXIT_FAILURE; } status = ftruncate(fd, 100); if (status!=0) { perror("shm_creator"); return EXIT_FAILURE; } buffer=mmap(0,100,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); if (buffer == MAP_FAILED) { perror("shm_creator"); return EXIT_FAILURE; } sprintf(buffer, "It's a nice day today, isn't it?"); printf("shm_creator: %s\n", buffer); return EXIT_SUCCESS; }

,

shm_open():

fd = shm_open("/swd_es", O_RDWR|O_CREAT, 0777);

(

"/swd_es" —

,

,

);

Пр и еча ие , /, /dev/shmem. /dev/shmem/swd_es.

,

"

:

O_RDONLY — O_RDWR —

" —

; ;

O_CREAT —

, shm_open().

,

,

O_CREAT

,

O_EXCL;

O_EXCL —

O_CREAT.

, shm_open()

, ;

O_TRUNC —

, / (

.

). (

.

4). fd,

. , .

shm_ctl():

ftruncate(fd, 100); fd,

shm_open();

Пр и еча ие ftrancate()

shm_ctl().

,

, :

buffer = mmap(0, 100, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

— (100)

. , ( ).

, :

PROT_EXEC —

;

PROT_NOCACHE — PROT_NONE — PROT_READ — PROT_WRITE —

; ; ; .

Ч

. MAP_SHARED (

). —

.

mmap() ,

(buffer). . ,

, , (

,

,

mmap()). :

sprintf(buffer, "It's a nice day today, isn't it?"); shm_user.c: #include #include #include int main() { int fd; char *buffer; fd = shm_open("/swd_es", O_RDONLY, 0777); if( fd == -1 ) { perror("shm_user"); return EXIT_FAILURE; } buffer = mmap(0, 100, PROT_READ, MAP_SHARED, fd, 0 ); if (buffer == MAP_FAILED) { perror("shm_user"); return EXIT_FAILURE; } printf("shm_user: %s\n", buffer); munmap(buffer, sizeof (buffer)); return EXIT_SUCCESS; }

К

, shm_open(). , mmap().

buffer

,

. :

printf("shm_user: %s\n", buffer);

.

,

, ,

. :

,

, ,

?



:

, . POSIX.

2.4.3.

POSIX

QNX Neutrino

POSIX.К , ,

POSIX. UNIX.

И QNX Neutrino . 3).

mqueue (

: sem_t * mySem; mySem = sem_open( "/my_semaphore", O_CREAT, 0777, 5);

sem_open() — /dev/sem/my_semaphore),

(

, .

,

,

. Пр и еча ие , " "

".

" 3.

, ,

,

5,

mySem.

, (

, sem_wait(),

), :

sem_wait(mySem);

,

sem_wait(), ,

. "

-

,

", sem_post(),

К ?

:"

".

,

. —

Neutrino. .

, —

"

"

, sem_trywait(), , " " .

, , ,—

. , . , — ,

Э

.

. "

",

) (

.

( QNX Neutrino

3).

,

sem_init(),

: sem_t * mySem; sem_init(mySem, 1, 5);

, 5 (

mySem

, sem_init()

).

, — 1. —

"

"

" -

".

0, .

Э

-0, . .

щ

POSIX POSIX

Neutrino mqueue.

, : /

— mq_open(); — mq_send(); — mq_recieve(). POSIX

"

" (/),

/dev/mqueue.

.

2.5. К ,

, ,

/

, . ,

"

",

, shell " " (shell script — "). , .

"

(

,

- ,

.

).

З К

shell —

, "Hello world!".

,

,

, hello.sh.

: echo Hello world!

Пр и еча ие , .

shell

,

,

,

?

-

, ☺.

50%



shell-

,

? : , .

:

sh hello.sh

, .

:

sh < hello.sh

shell (.).

"

"

:

. hello.sh

" .

"

:

chmod 755 cmd hello.sh

. , ,

PATH,

. К

"

"

.

, Empress ,

. ,

. ,

:

shell, …

А shell

, "

.

", ,

Empress. ,

, .

. К ,

, ,

? ,

#!

,

,

,

:

#!/bin/bash

Пр и еча ие . ,

# . hello.sh: #!/bin/ksh echo Hello world! # This is comment # This is comment too

, shell,

А

. .

shell

, ,

. .

,

, . Пр и еча ие shell , .

shell

( , (=).

).

Пр и еча ие =—

shell-

.

,

aaaa:

MY_VAR

MY_VAR=aaaa

:

MY_VAR1 MY_VAR1=

, —

.

shell:

MY_VAR2=123 MY_VAR2,

ASCII-

"123",

123! ,

,

: MY_VAR3="QNX Neutrino RTOS v.6.3.0"

Ч

, $.

,

echo MY_VAR3,

: echo $MY_VAR3

,

, ? ,

:

DATE=`date` date, DATE.

,

, .

echo ${MY_VAR3}beta1

: QNX Neutrino RTOS v.6.3.0beta1

, ,

read.

,

:

:

read A

,

.

-

. A

. ,

:

read A B C

,

script1.sh:

#!/bin/ksh echo –n Input variables A, B, and C: read A B C echo A=$A echo B=$B echo C=$C

: chmod a+x script1.sh ./script1.sh Input variables A, B, and C: 111 222 333,

( , ☺).

, :

Input variables A, B, and C:111 222 333

,

,

111 222 333 444 555

, ,

.

Пр и еча ие ,



(\).

,

,

A

$B,

:

A='$B'

: A=$B.

echo A=$A

, ,

shell shell

,

. expr. #!/bin/ksh x=50 y=4 a=`expr $x b=`expr $x c=`expr $x d=`expr $x e=`expr $x

script2.sh:

+ $y`; echo a=$a - $y`; echo b=$b / $y`; echo c=$c "*" $y`; echo d=$d % $y`; echo e=$e

.

:

a=54 b=46 c=12 d=200 e=2

, .

%.

,

(

. .*—

— *)

, .

shell,

Пр и еча ие , .

— shell-

. ksh,

(

"

"). ,

ksh,

". Э ,

"

.

— :

VAR1=myvar ... export VAR1



:

export VAR1=myvar

, ,

,

export

.

Пр и еча ие shell

(

)

.

set

shell shell

, (

Та я

. 2.1).

и а 2.1. В

З

?

К

$

PID

ksh

!

PID

,

#

Ч

(0 — )

,

shell

*

shell

@

shell ,

-

shell

Пр и еча ие $* $@ "111 222 333",

,

, "111" "222"

$*

$@

"333".

К

. Ч

, ,

(

)

shell,

, ?

. К

shell

, 0 ,

9.

0 1—

,

. . #.

2—

,

,

, 30

, ?

- ,

,



, ,

? А

shift. Ч

,

,

Word: , Word; ("

, ). А

" "

,

1–9

"

. shift

.

.

0 script3.sh:

#!/bin/ksh echo "Parameters =" ${#} echo -----------------echo "Param0 =" $0 echo "Param1 =" $1 echo "Param2 =" $2 echo "Param3 =" $3 echo -----------------shift 2 echo "Param0 =" $0 echo "Param1 =" $1 echo "Param2 =" $2 echo "Param3 =" $3

,

,

,

: chmod a+x script3.sh ./script3.sh AAA BBB CCC DDD EEE

set.

,

. —

set –v,

, set +v.

;

(

)—

set -x,

;

set +x.

я

я Korn Shell

К

, Korn Shell

? (

),

:

test if case for while until

test,

[] .

test

, "

"

. ". Э

"

if

, , ", 1 — "

test ? (0 — "

").

, : вие

test [

вие ]

Пр и еча ие .



,

.

,

; ; . : test -f myfile.txt — "

;

",

myfile.txt —

:

test -d mydir — " test

-c

",

mydir —

myfile —"

",

;

myfile —

; test -r myfile.txt — "

",

myfile.txt

",

myfile.txt

; test -w myfile.txt — "

; test -s myfile.txt — "

",

.

myfile.txt

: test aaa = bbb — " bbb;

",

test aaa != bbb — " bbb; test -n $A — "

",

test -z $A — "

",

",

aaa А

A—

,

(

);

( . .

). "

test

вие —

.

POSIX "

aaa

" ☺.

",

test, — true

",

false. Ч

: test x -eq y — "

",

x=y;

test x -ne y — "

",

x!=y;

test x -gt y — "

",

x>y;

test x -ge y — "

",

x>=y;

test x -lt y — "

",

x