有没有其他指标磁盘如何处理并行访问?我正在尝试调整我的程序将用于磁盘绑定 *** 作的线程数.
我对原始速度或寻道时间不感兴趣,只有哪种类型的访问 – 串行或并行 – 对驱动器来说更快.我不希望我的程序用户使用iSCSI或RAID. SSD是我的重点,其他任何东西都是很好的.
IOAHCIBlockStorageDevice的设备特征包含此信息.我怎么能以编程方式阅读它?
到目前为止,我已经发现它是这样的:(以下是伪代码)
match = IOBSD@R_502_6889@Matching(kIOMasterPortDefault,"disk0s2");IOServiceGetMatchingServices(kIOMasterPortDefault,match,&iterator);while(entry = IOIteratorNext(iterator)) { do { entry = IORegistryEntryGetParentEntry(nextMedia,kIOServicePlane,&entry); dict = IORegistryEntryCreateCFProperty(nextMedia,CFSTR(kIOPropertyDevicecharacteristicsKey),kcfAllocatorDefault,0); [dict objectForKey:CFSTR(kIOPropertyMediumTypeKey)]; } while(!dict && entry); }
编辑:Here’s complete source code.我已经验证它适用于英特尔SSD和OCZ Vertex.
解决方法 如果您正在尝试获取此类信息,那么最好的猜测是IOKit.您可以使用ioreg命令行工具或IORegistryExplorer尝试其中一些功能.
这里有一些可能对您有帮助的代码.它获取所有不是RAID且不是分区的硬盘驱动器.这不是你想要的,但它可能会让你开始.
#import "TWDevice.h"#include <stdio.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <sys/ioctl.h>#include <errno.h>#include <paths.h>#include <sys/param.h>#include <IOKit/IOKitlib.h>#include <IOKit/IOBSD.h>#include <IOKit/storage/IOMedia.h>#include <CoreFoundation/CoreFoundation.h>#include <IOKit/Kext/KextManager.h>@implementation TWDevice@synthesize @R_502_6889@,devicePath,size,blockSize,writable,icon;+ (NSArray *)allDevices { // create matching dictionary cfmutabledictionaryRef classesToMatch; classesToMatch = IOServiceMatching(kIOMediaClass); if (classesToMatch == NulL) { [NSException raise:@"TWError" format:@"Classes to match Could not be created"]; } // get iterator of matching services io_iterator_t mediaIterator; kern_return_t kernResult; kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault,classesToMatch,&mediaIterator); if (kernResult != KERN_SUCCESS) { [NSException raise:@"TWError" format:@"Matching services dID not succed."]; } // iterate over all found medias io_object_t nextMedia; NSMutableArray *detectedDevices = [NSMutableArray array]; while (nextMedia = IOIteratorNext(mediaIterator)) { NSMutableDictionary *propertIEs; kernResult = IORegistryEntryCreateCFPropertIEs(nextMedia,(cfmutabledictionaryRef *)&propertIEs,0); if (kernResult != KERN_SUCCESS) { [NSException raise:@"TWError" format:@"Getting propertIEs threw error."]; } // is it a whole device or just a partition? if ([[propertIEs valueForKey:@"Whole"] boolValue] && ![[propertIEs valueForKey:@"RAID"] boolValue]) { TWDevice *device = [[[TWDevice alloc] init] autorelease]; device.devicePath = [Nsstring stringWithFormat:@"%sr%@",_PATH_DEV,[propertIEs valueForKey:@"BSD @R_502_6889@"]]; device.blockSize = [[propertIEs valueForKey:@"Preferred Block Size"] unsignedLongLongValue]; device.writable = [[propertIEs valueForKey:@"Writable"] boolValue]; device.size = [[propertIEs valueForKey:@"Size"] unsignedLongLongValue]; io_@R_502_6889@_t @R_502_6889@; IORegistryEntryGet@R_502_6889@(nextMedia,@R_502_6889@); device.@R_502_6889@ = [Nsstring stringWithCString:@R_502_6889@ enCoding:NSASCIIStringEnCoding]; … [detectedDevices addobject:device]; } // tIDy up IOObjectRelease(nextMedia); CFRelease(propertIEs); } IOObjectRelease(mediaIterator); return detectedDevices;}@end总结
以上是内存溢出为你收集整理的cocoa – 如何在Mac OS X中检测SSD?全部内容,希望文章能够帮你解决cocoa – 如何在Mac OS X中检测SSD?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)