function setDSWPriorities(extModelH,ssIOActivity,origSysH)
    
    % If Data Store Memories are used in slice subsystem,
    % all DSW needs to be executed before extracted subsysystem is called.
    
    % Copyright 2014 The MathWorks, Inc.
    
    if isempty(ssIOActivity.DataStoreName.Active)
        % Nothing to do when there is no active DSM
        return;
    end

    % Obtain priority set on the extracted slice subsystem
    extSysH = find_system(extModelH,'FindAll','on','SearchDepth',1,...
        'BlockType','SubSystem','Name',get_param(origSysH,'Name'));
    assert(length(extSysH) == 1);

    % If no priority is set or having error, we set 0.
    extSysPriorityStr = get_param(extSysH,'Priority');
    if isempty(extSysPriorityStr)
        extSysPriority = 0;
    else
        try
            extSysPriority = evalin('base',extSysPriorityStr);
        catch
            extSysPriority = 0;
        end
    end
    
    % Setting all DSWs to have -1 of slice subsystem.
    DSWBlks = find_system(extModelH,'FindAll','on','SearchDepth',1,...
        'BlockType','DataStoreWrite');
    for n=1:length(DSWBlks)
        set_param(DSWBlks(n),'Priority',num2str(extSysPriority-1));
    end
    
end