1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
|
'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH LGRP 3PERL "Aug 30, 2006"
.SH NAME
Lgrp \- Perl interface to Solaris liblgrp library
.SH SYNOPSIS
.LP
.nf
use Sun::Solaris::Lgrp qw(:ALL);
# initialize lgroup interface
my $cookie = lgrp_init(LGRP_VIEW_OS | LGRP_VIEW_CALLER);
my $l = Sun::Solaris::Lgrp->new(LGRP_VIEW_OS |
LGRP_VIEW_CALLER);
my $version = lgrp_version(LGRP_VER_CURRENT | LGRP_VER_NONE);
$version = $l->version(LGRP_VER_CURRENT | LGRP_VER_NONE);
$home = lgrp_home(P_PID, P_MYID);
$home = l->home(P_PID, P_MYID);
lgrp_affinity_set(P_PID, $\fIpid\fR, $\fIlgrp\fR,
LGRP_AFF_STRONG | LGRP_AFF_WEAK | LGRP_AFF_NONE);
$l->affinity_set(P_PID, $\fIpid\fR, $\fIlgrp\fR,
LGRP_AFF_STRONG | LGRP_AFF_WEAK | LGRP_AFF_NONE);
my $affinity = lgrp_affinity_get(P_PID, $\fIpid\fR, $\fIlgrp\fR);
$affinity = $l->affinity_get(P_PID, $\fIpid\fR, $\fIlgrp\fR);
my $nlgrps = lgrp_nlgrps($\fIcookie\fR);
$nlgrps = $l->nlgrps();
my $root = lgrp_root($\fIcookie\fR);
$root = l->root();
$latency = lgrp_latency($\fIlgrp1\fR, $\fIlgrp2\fR);
$latency = $l->latency($\fIlgrp1\fR, $\fIlgrp2\fR);
my @children = lgrp_children($\fIcookie\fR, $\fIlgrp\fR);
@children = l->children($lgrp);
my @parents = lgrp_parents($\fIcookie\fR, $\fIlgrp\fR);
@parents = l->parents($\fIlgrp\fR);
my @lgrps = lgrp_lgrps($\fIcookie\fR);
@lgrps = l->lgrps();
@lgrps = lgrp_lgrps($\fIcookie\fR, $\fIlgrp\fR);
@lgrps = l->lgrps($\fIlgrp\fR);
my @leaves = lgrp_leaves($\fIcookie\fR);
@leaves = l->leaves();
my $is_leaf = lgrp_isleaf($\fIcookie\fR, $\fIlgrp\fR);
$is_leaf = $l->is_leaf($\fIlgrp\fR);
my @cpus = lgrp_cpus($\fIcookie\fR, $\fIlgrp\fR,
LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
@cpus = l->cpus($\fIlgrp\fR, LGRP_CONTENT_HIERARCHY |
LGRP_CONTENT_DIRECT);
my $memsize = lgrp_mem_size($\fIcookie\fR, $\fIlgrp\fR,
LGRP_MEM_SZ_INSTALLED | LGRP_MEM_SZ_FREE,
LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
$memsize = l->mem_size($\fIlgrp\fR,
LGRP_MEM_SZ_INSTALLED | LGRP_MEM_SZ_FREE,
LGRP_CONTENT_HIERARCHY | LGRP_CONTENT_DIRECT);
my $is_stale = lgrp_cookie_stale($\fIcookie\fR);
$stale = l->stale();
lgrp_fini($\fIcookie\fR);
# The following is available for API version greater than 1:
my @lgrps = lgrp_resources($\fIcookie\fR, $\fIlgrp\fR, LGRP_RSRC_CPU);
# Get latencies from cookie
$latency = lgrp_latency_cookie($\fIcookie\fR, $\fIfrom\fR, $\fIto\fR);
.fi
.SH DESCRIPTION
.sp
.LP
This module provides access to the \fBliblgrp\fR(3LIB) library and to various
constants and functions defined in <\fBsys/lgrp_sys.h\fR>. It provides both the
procedural and object interface to the library. The procedural interface
requires (in most cases) passing around a transparent cookie. The object
interface hides all the cookie manipulations from the user.
.sp
.LP
Functions returning a scalar value indicate an error by returning \fBundef\fR.
The caller can examine the \fB$!\fR variable to get the error value.
.sp
.LP
Functions returning a list value return the number of elements in the list when
called in scalar context. In the event of error, the empty list is returned in
the array context and \fBundef\fR is returned in the scalar context.
.SS "Constants"
.sp
.LP
The constants are exported with \fB:CONSTANTS\fR or \fB:ALL\fR tags:
.sp
.in +2
.nf
use Sun::Solaris::Lgrp ':ALL';
.fi
.in -2
.sp
.LP
or
.sp
.in +2
.nf
use Sun::Solaris::Lgrp ':CONSTANTS';
.fi
.in -2
.sp
.LP
The following constants are available for use in Perl programs:
.br
.in +2
\fBLGRP_NONE\fR
.in -2
.br
.in +2
\fBLGRP_VER_CURRENT\fR
.in -2
.br
.in +2
\fBLGRP_VER_NONE\fR
.in -2
.br
.in +2
\fBLGRP_VIEW_CALLER\fR
.in -2
.br
.in +2
\fBLGRP_VIEW_OS\fR
.in -2
.br
.in +2
\fBLGRP_AFF_NONE\fR
.in -2
.br
.in +2
\fBLGRP_AFF_STRONG\fR
.in -2
.br
.in +2
\fBLGRP_AFF_WEAK\fR
.in -2
.br
.in +2
\fBLGRP_CONTENT_DIRECT\fR
.in -2
.br
.in +2
\fBLGRP_CONTENT_HIERARCHY\fR
.in -2
.br
.in +2
\fBLGRP_MEM_SZ_FREE\fR
.in -2
.br
.in +2
\fBLGRP_MEM_SZ_FREE\fR
.in -2
.br
.in +2
\fBLGRP_RSRC_CPU\fR (1)
.in -2
.br
.in +2
\fBLGRP_RSRC_MEM\fR (1)
.in -2
.br
.in +2
\fBLGRP_CONTENT_ALL\fR (1)
.in -2
.br
.in +2
\fBLGRP_LAT_CPU_TO_MEM\fR (1)
.in -2
.br
.in +2
\fBP_PID\fR
.in -2
.br
.in +2
\fBP_LWPID\fR
.in -2
.br
.in +2
\fBP_MYID\fR
.in -2
.sp
.LP
(1) Available for versions of the \fBliblgrp\fR(3LIB) API greater than 1.
.SS "Functions"
.sp
.LP
A detailed description of each function follows. Since this module is intended
to provide a Perl interface to the functions in \fBliblgrp\fR(3LIB), a very
short description is given for the corresponding functions in this module and a
reference is given to the complete description in the \fBliblgrp\fR manual
pages. Any differences or additional functionality in the Perl module are
highlighted and fully documented here.
.sp
.ne 2
.na
\fB\fBlgrp_init([LGRP_VIEW_CALLER | LGRP_VIEW_OS])\fR\fR
.ad
.sp .6
.RS 4n
This function initializes the lgroup interface and takes a snapshot of the
lgroup hierarchy with the given view. Given the view, \fBlgrp_init()\fR returns
a cookie representing this snapshot of the lgroup hierarchy. This cookie should
be used with other routines in the lgroup interface needing the lgroup
hierarchy. The \fBlgrp_fini()\fR function should be called with the cookie when
it is no longer needed. Unlike \fBlgrp_init\fR(3LGRP), \fBLGRP_VIEW_OS\fR is
assumed as the default if no view is provided.
.sp
Upon successful completion, \fBlgrp_init()\fR returns a cookie. Otherwise it
returns \fBundef\fR and sets \fB$!\fR to indicate the error.
.sp
See \fBlgrp_init\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_fini\fR($\fIcookie\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie, frees the snapshot of the lgroup hierarchy
created by \fBlgrp_init()\fR, and cleans up anything else set up by
\fBlgrp_init()\fR. After this function is called, the cookie returned by the
lgroup interface might no longer be valid and should not be used.
.sp
Upon successful completion, 1 is returned. Otherwise, \fBundef\fR is returned
and \fB$!\fR is set to indicate the error.
.sp
See \fBlgrp_fini\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_view\fR($\fIcookie\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing the snapshot of the lgroup hierarchy
and returns the snapshot's view of the lgroup hierarchy.
.sp
If the given view is \fBLGRP_VIEW_CALLER\fR, the snapshot contains only the
resources that are available to the caller (such as those with respect to
processor sets). When the view is \fBLGRP_VIEW_OS\fR, the snapshot contains
what is available to the operating system.
.sp
Upon succesful completion, the function returns the view for the snapshot of
the lgroup hierarchy represented by the given cookie. Otherwise, \fBundef\fR
is returned and \fB$!\fR is set to indicate the error.
.sp
See \fBlgrp_view\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_home\fR($\fIidtype\fR, $\fIid\fR)\fR
.ad
.sp .6
.RS 4n
This function returns the home lgroup for the given process or thread. The
$\fIidtype\fR argument should be \fBP_PID\fR to specify a process and the
$\fIid\fR argument should be its process ID. Otherwise, the $\fIidtype\fR
argument should be \fBP_LWPID\fR to specify a thread and the $\fIid\fR argument
should be its LWP ID. The value \fBP_MYID\fR can be used for the $\fIid\fR
argument to specify the current process or thread.
.sp
Upon successful completion, \fBlgrp_home()\fR returns the ID of the home lgroup
of the specified process or thread. Otherwise, \fBundef\fR is returned and
\fB$!\fR is set to indicate the error.
.sp
See \fBlgrp_home\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_cookie_stale\fR($\fIcookie\fR)\fR
.ad
.sp .6
.RS 4n
Upon successful completion, this function returns whether the cookie is stale.
Otherwise, it returns \fBundef\fR and sets \fB$!\fR to indicate the error.
.sp
The \fBlgrp_cookie_stale()\fR function will fail with \fBEINVAL\fR if the
cookie is not valid.
.sp
See \fBlgrp_cookie_stale\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_cpus\fR($\fIcookie\fR, $\fIlgrp\fR, $\fIcontext\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy
and returns the list of CPUs in the lgroup specified by $\fIlgrp\fR. The
$\fIcontext\fR argument should be set to one of the following values to specify
whether the direct contents or everything in this lgroup including its children
should be returned:
.sp
.ne 2
.na
\fB\fBLGRP_CONTENT_HIERARCHY\fR\fR
.ad
.RS 26n
everything within this hierarchy
.RE
.sp
.ne 2
.na
\fB\fBLGRP_CONTENT_DIRECT\fR\fR
.ad
.RS 26n
directly contained in lgroup
.RE
When called in scalar context, \fBlgrp_cpus()\fR function returns the number of
CPUs contained in the specified lgroup.
.sp
In the event of error, \fBundef\fR is returned in scalar context and \fB$!\fR
is set to indicate the error. In list context, the empty list is returned and
\fB$!\fR is set.
.sp
See \fBlgrp_cpus\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_children\fR($\fIcookie\fR, $\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy
and returns the list of lgroups that are children of the specified lgroup.
.sp
When called in scalar context, \fBlgrp_children()\fR returns the number of
children lgroups for the specified lgroup.
.sp
In the event of error, \fBundef\fR or empty list is returned and \fB$!\fR is
set to indicate the error.
.sp
See \fBlgrp_children\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_parents\fR($\fIcookie\fR, $\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy
and returns the list of parents of the specified lgroup.
.sp
When called in scalar context, \fBlgrp_parents()\fR returns the number of
parent lgroups for the specified lgroup.
.sp
In the event of error, \fBundef\fR or an empty list is returned and \fB$!\fR is
set to indicate the error.
.sp
See \fBlgrp_parents\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_nlgrps\fR($\fIcookie\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy.
It returns the number of lgroups in the hierarchy, where the number is always
at least one.
.sp
In the event of error, \fBundef\fR is returned and \fB$!\fR is set to
\fBEINVAL\fR, indicating that the cookie is not valid.
.sp
See \fBlgrp_nlgrps\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_root\fR($\fIcookie\fR)\fR
.ad
.sp .6
.RS 4n
This function returns the root lgroup ID.
.sp
In the event of error, \fBundef\fR is returned and \fB$!\fR is set to
\fBEINVAL\fR, indicatng that the cookie is not valid.
.sp
See \fBlgrp_root\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_mem_size\fR($\fIcookie\fR, $\fIlgrp\fR, $\fItype\fR,
$\fIcontent\fR)\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy.
The function returns the memory size of the given lgroup in bytes. The
$\fItype\fR argument should be set to one of the following values:
.sp
.ne 2
.na
\fB\fBLGRP_MEM_SZ_FREE\fR\fR
.ad
.RS 25n
free memory
.RE
.sp
.ne 2
.na
\fB\fBLGRP_MEM_SZ_INSTALLED\fR\fR
.ad
.RS 25n
installed memory
.RE
The $\fIcontent\fR argument should be set to one of the following values to
specify whether the direct contents or everything in this lgroup including its
children should be returned:
.sp
.ne 2
.na
\fB\fBLGRP_CONTENT_HIERARCHY\fR\fR
.ad
.RS 26n
Return everything within this hierarchy.
.RE
.sp
.ne 2
.na
\fB\fBLGRP_CONTENT_DIRECT\fR\fR
.ad
.RS 26n
Return that which is directly contained in this lgroup.
.RE
The total sizes include all the memory in the lgroup including its children,
while the others reflect only the memory contained directly in the given
lgroup.
.sp
Upon successful completion, the size in bytes is returned. Otherwise,
\fBundef\fR is returned and \fB$!\fR is set to indicate the error.
.sp
See \fBlgrp_mem_size\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_version\fR([$\fIversion\fR])\fR
.ad
.sp .6
.RS 4n
This function takes an interface version number, $\fIversion\fR, as an argument
and returns an lgroup interface version. The $\fIversion\fR argument should be
the value of \fBLGRP_VER_CURRENT\fR or \fBLGRP_VER_NONE\fR to find out the
current lgroup interface version on the running system.
.sp
If $\fIversion\fR is still supported by the implementation, then
\fBlgrp_version()\fR returns the requested version. If \fBLGRP_VER_NONE\fR is
returned, the implementation cannot support the requested version.
.sp
If $\fIversion\fR is \fBLGRP_VER_NONE\fR, \fBlgrp_version()\fR returns the
current version of the library.
.sp
The following example tests whether the version of the interface used by the
caller is supported:
.sp
.in +2
.nf
lgrp_version(LGRP_VER_CURRENT) == LGRP_VER_CURRENT or
die("Built with unsupported lgroup interface");
.fi
.in -2
See \fBlgrp_version\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_affinity_set\fR($\fIidtype\fR, $\fIid\fR, $\fIlgrp\fR,
$\fIaffinity\fR)\fR
.ad
.sp .6
.RS 4n
This function sets the affinity that the LWP or set of LWPs specified by
$\fIidtype\fR and $\fIid\fR have for the given lgroup. The lgroup affinity can
be set to \fBLGRP_AFF_STRONG\fR, \fBLGRP_AFF_WEAK\fR, or \fBLGRP_AFF_NONE\fR.
.sp
If the $\fIidtype\fR is \fBP_PID\fR, the affinity is retrieved for one of the
LWPs in the process or set for all the LWPs of the process with process ID
(PID) $\fIid\fR. The affinity is retrieved or set for the LWP of the current
process with LWP ID $\fIid\fR if $\fIidtype\fR is \fBP_LWPID\fR. If $\fIid\fR
is \fBP_MYID\fR, then the current LWP or process is specified.
.sp
There are different levels of affinity that can be specified by a thread for a
particuliar lgroup. The levels of affinity are the following from strongest to
weakest:
.sp
.ne 2
.na
\fB\fBLGRP_AFF_STRONG\fR\fR
.ad
.RS 19n
strong affinity
.RE
.sp
.ne 2
.na
\fB\fBLGRP_AFF_WEAK\fR\fR
.ad
.RS 19n
weak affinity
.RE
.sp
.ne 2
.na
\fB\fBLGRP_AFF_NONE\fR\fR
.ad
.RS 19n
no affinity
.RE
Upon successful completion, \fBlgrp_affinity_set()\fR returns 1. Otherwise, it
returns \fBundef\fR and set \fB$!\fR to indicate the error.
.sp
See \fBlgrp_affinity_set\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_affinity_get\fR($\fIidtype\fR, $\fIid\fR, $\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This function returns the affinity that the LWP has to a given lgroup.
.sp
See \fBlgrp_affinity_get\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_latency_cookie\fR($\fIcookie\fR, $\fIfrom\fR, $\fIto\fR,
[$\fIbetween\fR=\fBLGRP_LAT_CPU_TO_MEM\fR])\fR
.ad
.sp .6
.RS 4n
This function takes a cookie representing a snapshot of the lgroup hierarchy
and returns the latency value between a hardware resource in the $\fIfrom\fR
lgroup to a hardware resource in the $\fIto\fR lgroup. If $\fIfrom\fR is the
same lgroup as $\fIto\fR, the latency value within that lgroup is returned.
.sp
The optional $\fIbetween\fR argument should be set to \fBLGRP_LAT_CPU_TO_MEM\fR
to specify between which hardware resources the latency should be measured. The
only valid value is \fBLGRP_LAT_CPU_TO_MEM\fR, which represents latency from
CPU to memory.
.sp
Upon successful completion, \fBlgrp_latency_cookie()\fR return 1. Otherwise,
it returns \fBundef\fR and set \fB$!\fR to indicate the error. For LGRP API
version 1, the \fBlgrp_latency_cookie()\fR is an alias for
\fBlgrp_latency.()\fR
.sp
See \fBlgrp_latency_cookie\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_latency\fR($\fIfrom\fR, $\fIto\fR)\fR
.ad
.sp .6
.RS 4n
This function is similiar to the \fBlgrp_latency_cookie()\fR function, but
returns the latency between the given lgroups at the given instant in time.
Since lgroups can be freed and reallocated, this function might not be able to
provide a consistent answer across calls. For that reason,
\fBlgrp_latency_cookie()\fR should be used in its place.
.sp
See \fBlgrp_latency\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_resources\fR($\fIcookie\fR, $\fIlgrp\fR, $\fItype\fR)\fR
.ad
.sp .6
.RS 4n
This function returns the list of lgroups directly containing resources of the
specified type. The resources are represented by a set of lgroups in which each
lgroup directly contains CPU and/or memory resources.
.sp
The \fItype\fR can be specified as:
.sp
.ne 2
.na
\fB\fBLGRP_RSRC_CPU\fR\fR
.ad
.RS 17n
CPU resources
.RE
.sp
.ne 2
.na
\fB\fBLGRP_RSRC_MEM\fR\fR
.ad
.RS 17n
memory resources
.RE
In the event of error, \fBundef\fR or an empty list is returned and \fB$!\fR is
set to indicate the error.
.sp
This function is available only for API version 2 and returns \fBundef\fR or an
empty list for API version 1 and sets \fB$!\fR to \fBEINVAL\fR.
.sp
See \fBlgrp_resources\fR(3LGRP) for more information.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_lgrps\fR($\fIcookie\fR, [$\fIlgrp\fR])\fR
.ad
.sp .6
.RS 4n
This function returns a list of all lgroups in a hierarchy starting from
$\fIlgrp\fR. If $\fIlgrp\fR is not specified, uses the value of
\fBlgrp_root\fR($\fIcookie\fR). This function returns the empty list on
failure.
.sp
When called in scalar context, this function returns the total number of
lgroups in the system.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_leaves\fR($\fIcookie\fR, [$\fIlgrp\fR])\fR
.ad
.sp .6
.RS 4n
This function returns a list of all leaf lgroups in a hierarchy starting from
$\fIlgrp\fR. If $\fIlgrp\fR is not specified, this function uses the value of
\fBlgrp_root\fR($\fIcookie\fR). It returns \fBundef\fR or an empty list on
failure.
.sp
When called in scalar context, this function returns the total number of leaf
lgroups in the system.
.RE
.sp
.ne 2
.na
\fB\fBlgrp_isleaf\fR($\fIcookie\fR, $\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This function returns True if $\fIlgrp\fR is a leaf (has no children).
Otherwise it returns False.
.RE
.SS "Object methods"
.sp
.ne 2
.na
\fB\fBnew\fR([$\fIview\fR])\fR
.ad
.sp .6
.RS 4n
This method creates a new \fBSun::Solaris::Lgrp\fR object. An optional argument
is passed to the \fBlgrp_init()\fR function. By default this method uses
\fBLGRP_VIEW_OS\fR.
.RE
.sp
.ne 2
.na
\fB\fBcookie()\fR\fR
.ad
.sp .6
.RS 4n
This method returns a transparent cookie that can be passed to functions
accepting the cookie.
.RE
.sp
.ne 2
.na
\fB\fBversion\fR([$\fIversion\fR])\fR
.ad
.sp .6
.RS 4n
Without the argument, this method returns the current version of the
\fBliblgrp\fR(3LIB) library. This method is a wrapper for \fBlgrp_version()\fR
with \fBLGRP_VER_NONE\fR as the default version argument.
.RE
.sp
.ne 2
.na
\fB\fBstale()\fR\fR
.ad
.sp .6
.RS 4n
This method returns T if the lgroup information in the object is stale and F
otherwise. It is a wrapper for \fBlgrp_cookie_stale()\fR.
.RE
.sp
.ne 2
.na
\fB\fBview()\fR\fR
.ad
.sp .6
.RS 4n
This method returns the snapshot's view of the lgroup hierarchy. It is a
wrapper for \fBlgrp_view()\fR.
.RE
.sp
.ne 2
.na
\fB\fBroot()\fR\fR
.ad
.sp .6
.RS 4n
This method returns the root lgroup. It is a wrapper for \fBlgrp_root()\fR.
.RE
.sp
.ne 2
.na
\fB\fBchildren\fR($\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the list of lgroups that are children of the specified
lgroup. It is a wrapper for \fBlgrp_children()\fR.
.RE
.sp
.ne 2
.na
\fB\fBparents\fR($\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the list of lgroups that are parents of the specified
lgroup. It is a wrapper for \fBlgrp_parents()\fR.
.RE
.sp
.ne 2
.na
\fB\fBnlgrps()\fR\fR
.ad
.sp .6
.RS 4n
This method returns the number of lgroups in the hierarchy. It is a wrapper for
\fBlgrp_nlgrps()\fR.
.RE
.sp
.ne 2
.na
\fB\fBmem_size\fR($\fIlgrp\fR, $\fItype\fR, $\fIcontent\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the memory size of the given lgroup in bytes. It is a
wrapper for \fBlgrp_mem_size()\fR.
.RE
.sp
.ne 2
.na
\fB\fBcpus\fR($\fIlgrp\fR, $\fIcontext\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the list of CPUs in the lgroup specified by $lgrp. It is a
wrapper for \fBlgrp_cpus()\fR.
.RE
.sp
.ne 2
.na
\fB\fBresources\fR($\fIlgrp\fR, $\fItype\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the list of lgroups directly containing resources of the
specified type. It is a wrapper for \fBlgrp_resources()\fR.
.RE
.sp
.ne 2
.na
\fB\fBhome\fR($\fIidtype\fR, $\fIid\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the home lgroup for the given process or thread. It is a
wrapper for \fBlgrp_home()\fR.
.RE
.sp
.ne 2
.na
\fB\fBaffinity_get\fR($\fIidtype\fR, $\fIid\fR, $\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the affinity that the LWP has to a given lgrp. It is a
wrapper for \fBlgrp_affinity_get()\fR.
.RE
.sp
.ne 2
.na
\fB\fBaffinity_set\fR($\fIidtype\fR, $\fIid\fR, $\fIlgrp\fR,
$\fIaffinity\fR)\fR
.ad
.sp .6
.RS 4n
This method sets the affinity that the LWP or set of LWPs specified by
$\fIidtype\fR and $\fIid\fR have for the given lgroup. It is a wrapper for
lgrp_affinity_set.
.RE
.sp
.ne 2
.na
\fB\fBlgrps\fR([$\fIlgrp\fR])\fR
.ad
.sp .6
.RS 4n
This method returns list of all lgroups in a hierarchy starting from
$\fIlgrp\fR or the \fBlgrp_root()\fR if $\fIlgrp\fR is not specified. It is a
wrapper for \fBlgrp_lgrps()\fR.
.RE
.sp
.ne 2
.na
\fB\fBleaves\fR([$\fIlgrp\fR])\fR
.ad
.sp .6
.RS 4n
This method returns a list of all leaf lgroups in a hierarchy starting from
$\fIlgrp\fR. If $\fIlgrp\fR is not specified, this method uses the value of
\fBlgrp_root()\fR. It is a wrapper for \fBlgrp_leaves()\fR.
.RE
.sp
.ne 2
.na
\fB\fBisleaf\fR($\fIlgrp\fR)\fR
.ad
.sp .6
.RS 4n
This method returns True if $\fIlgrp\fR is leaf (has no children) and False
otherwise. It is a wrapper for \fBlgrp_isleaf()\fR.
.RE
.sp
.ne 2
.na
\fB\fBlatency\fR($\fIfrom\fR, $\fIto\fR)\fR
.ad
.sp .6
.RS 4n
This method returns the latency value between a hardware resource in the
$\fIfrom\fR lgroup to a hardware resource in the $\fIto\fR lgroup. It uses
\fBlgrp_latency()\fR for version 1 of \fBliblgrp\fR and
\fBlgrp_latency_cookie()\fR for newer versions.
.RE
.SS "Exports"
.sp
.LP
By default nothing is exported from this module. The following tags can be used
to selectively import constants and functions defined in this module:
.sp
.ne 2
.na
\fB\fB:LGRP_CONSTANTS\fR\fR
.ad
.RS 19n
\fBLGRP_AFF_NONE\fR, \fBLGRP_AFF_STRONG\fR, \fBLGRP_AFF_WEAK\fR,
\fBLGRP_CONTENT_DIRECT\fR, \fBLGRP_CONTENT_HIERARCHY\fR,
\fBLGRP_MEM_SZ_FREE\fR, \fBLGRP_MEM_SZ_INSTALLED\fR, \fBLGRP_VER_CURRENT\fR,
\fBLGRP_VER_NONE\fR, \fBLGRP_VIEW_CALLER\fR, \fBLGRP_VIEW_OS\fR,
\fBLGRP_NONE\fR, \fBLGRP_RSRC_CPU\fR, \fBLGRP_RSRC_MEM\fR,
\fBLGRP_CONTENT_ALL\fR, \fBLGRP_LAT_CPU_TO_MEM\fR
.RE
.sp
.ne 2
.na
\fB\fB:PROC_CONSTANTS\fR\fR
.ad
.RS 19n
\fBP_PID\fR, \fBP_LWPID\fR, \fBP_MYID\fR
.RE
.sp
.ne 2
.na
\fB\fB:CONSTANTS\fR\fR
.ad
.RS 19n
\fB:LGRP_CONSTANTS\fR, \fB:PROC_CONSTANTS\fR
.RE
.sp
.ne 2
.na
\fB\fB:FUNCTIONS\fR\fR
.ad
.RS 19n
\fBlgrp_affinity_get()\fR, \fBlgrp_affinity_set()\fR, \fBlgrp_children()\fR,
\fBlgrp_cookie_stale()\fR, \fBlgrp_cpus()\fR, \fBlgrp_fini()\fR,
\fBlgrp_home()\fR, \fBlgrp_init()\fR, \fBlgrp_latency()\fR,
\fBlgrp_latency_cookie()\fR, \fBlgrp_mem_size()\fR, \fBlgrp_nlgrps()\fR,
\fBlgrp_parents()\fR, \fBlgrp_root()\fR, \fBlgrp_version()\fR,
\fBlgrp_view()\fR, \fBlgrp_resources()\fR, \fBlgrp_lgrps()\fR,
\fBlgrp_leaves()\fR, \fBlgrp_isleaf()\fR
.RE
.sp
.ne 2
.na
\fB\fB:ALL\fR\fR
.ad
.RS 19n
\fB:CONSTANTS\fR, \fB:FUNCTIONS\fR
.RE
.SS "Error values"
.sp
.LP
The functions in this module return \fBundef\fR or an empty list when an
underlying library function fails. The \fB$!\fR is set to provide more
information values for the error. The following error codes are possible:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The value supplied is not valid.
.RE
.sp
.ne 2
.na
\fB\fBENOMEM\fR\fR
.ad
.RS 10n
There was not enough system memory to complete an operation.
.RE
.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The effective user of the calling process does not have appropriate privileges,
and its real or effective user ID does not match the real or effective user ID
of one of the threads.
.RE
.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 10n
The specified process or thread was not found.
.RE
.SS "Difference in the API versions"
.sp
.LP
The \fBliblgrp\fR(3LIB) library is versioned. The exact version that was used
to compile a module is available through the \fBlgrp_version()\fR function.
.sp
.LP
Version 2 of the \fBlgrp_user\fR API introduced the following constants and
functions not present in version 1:
.br
.in +2
\fBLGRP_RSRC_CPU\fR constant
.in -2
.br
.in +2
\fBLGRP_RSRC_MEM\fR constant
.in -2
.br
.in +2
\fBLGRP_CONTENT_ALL\fR constant
.in -2
.br
.in +2
\fBLGRP_LAT_CPU_TO_MEM\fR constant
.in -2
.br
.in +2
\fBlgrp_resources()\fR function
.in -2
.br
.in +2
\fBlgrp_latency_cookie()\fR function
.in -2
.sp
.LP
The \fBLGRP_RSRC_CPU\fR and \fBLGRP_RSRC_MEM\fR constants are not defined for
version 1. The \fBlgrp_resources()\fR function is defined for version 1 but
always returns an empty list. The \fBlgrp_latency_cookie()\fR function is an
alias for \fBlgrp_latency()\fR for version 1.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Unstable
.TE
.SH SEE ALSO
.sp
.LP
\fBlgrp_affinity_get\fR(3LGRP), \fBlgrp_affinity_set\fR(3LGRP),
\fBlgrp_children\fR(3LGRP), \fBlgrp_cookie_stale\fR(3LGRP),
\fBlgrp_cpus\fR(3LGRP), \fBlgrp_fini\fR(3LGRP), \fBlgrp_home\fR(3LGRP),
\fBlgrp_init\fR(3LGRP), \fBlgrp_latency\fR(3LGRP),
\fBlgrp_latency_cookie\fR(3LGRP), \fBlgrp_mem_size\fR(3LGRP),
\fBlgrp_nlgrps\fR(3LGRP), \fBlgrp_parents\fR(3LGRP),
\fBlgrp_resources\fR(3LGRP), \fBlgrp_root\fR(3LGRP), \fBlgrp_version\fR(3LGRP),
\fBlgrp_view\fR(3LGRP), \fBliblgrp\fR(3LIB), \fBattributes\fR(5)
|